<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998


Utility functions on @Core@ syntax
-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-11"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Subst</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-12"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Main data types</span></span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier">Subst</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- Implementation exported for supercompiler's Renaming.hs only</span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier">TvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#IdSubstEnv"><span class="hs-identifier">IdSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier">InScopeSet</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Substituting into expressions and related types</span></span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#deShadowBinds"><span class="hs-identifier">deShadowBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substSpec"><span class="hs-identifier">substSpec</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substRulesForImportedIds"><span class="hs-identifier">substRulesForImportedIds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier">substTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier">substCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier">substExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substExprSC"><span class="hs-identifier">substExprSC</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substBind"><span class="hs-identifier">substBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substBindSC"><span class="hs-identifier">substBindSC</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#substUnfolding"><span class="hs-identifier">substUnfolding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substUnfoldingSC"><span class="hs-identifier">substUnfoldingSC</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier">lookupIdSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#lookupTCvSubst"><span class="hs-identifier">lookupTCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substIdType"><span class="hs-identifier">substIdType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substIdOcc"><span class="hs-identifier">substIdOcc</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#substTickish"><span class="hs-identifier">substTickish</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substDVarSet"><span class="hs-identifier">substDVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substIdInfo"><span class="hs-identifier">substIdInfo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Operations on substitutions</span></span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#emptySubst"><span class="hs-identifier">emptySubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#mkEmptySubst"><span class="hs-identifier">mkEmptySubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#mkSubst"><span class="hs-identifier">mkSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#mkOpenSubst"><span class="hs-identifier">mkOpenSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substInScope"><span class="hs-identifier">substInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#isEmptySubst"><span class="hs-identifier">isEmptySubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#extendIdSubst"><span class="hs-identifier">extendIdSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendIdSubstList"><span class="hs-identifier">extendIdSubstList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTCvSubst"><span class="hs-identifier">extendTCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendTvSubstList"><span class="hs-identifier">extendTvSubstList</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#extendSubst"><span class="hs-identifier">extendSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendSubstList"><span class="hs-identifier">extendSubstList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendSubstWithVar"><span class="hs-identifier">extendSubstWithVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#zapSubstEnv"><span class="hs-identifier">zapSubstEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#addInScopeSet"><span class="hs-identifier">addInScopeSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendInScope"><span class="hs-identifier">extendInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendInScopeList"><span class="hs-identifier">extendInScopeList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendInScopeIds"><span class="hs-identifier">extendInScopeIds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#isInScope"><span class="hs-identifier">isInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#setInScope"><span class="hs-identifier">setInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#getTCvSubst"><span class="hs-identifier">getTCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendTvSubst"><span class="hs-identifier">extendTvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#extendCvSubst"><span class="hs-identifier">extendCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#delBndr"><span class="hs-identifier">delBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#delBndrs"><span class="hs-identifier">delBndrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Substituting and cloning binders</span></span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier">substBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier">substBndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substRecBndrs"><span class="hs-identifier">substRecBndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substTyVarBndr"><span class="hs-identifier">substTyVarBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substCoVarBndr"><span class="hs-identifier">substCoVarBndr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="GHC.Core.Subst.html#cloneBndr"><span class="hs-identifier">cloneBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#cloneBndrs"><span class="hs-identifier">cloneBndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#cloneIdBndr"><span class="hs-identifier">cloneIdBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#cloneIdBndrs"><span class="hs-identifier">cloneIdBndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#cloneRecIdBndrs"><span class="hs-identifier">cloneRecIdBndrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-41"></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html"><span class="hs-identifier">GHC.Core.FVs</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Seq.html"><span class="hs-identifier">GHC.Core.Seq</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Type</span></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Coercion</span></span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span>        </span><span class="hs-comment">-- We are defining local versions</span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span> </span><span class="hs-keyword">hiding</span><span>
</span><span id="line-51"></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier">substTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubst"><span class="hs-identifier">extendTvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendCvSubst"><span class="hs-identifier">extendCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubstList"><span class="hs-identifier">extendTvSubstList</span></a></span><span>
</span><span id="line-52"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#isInScope"><span class="hs-identifier">isInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVarBndr"><span class="hs-identifier">substTyVarBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndr"><span class="hs-identifier">cloneTyVarBndr</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier">substCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVarBndr"><span class="hs-identifier">substCoVarBndr</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier">Name</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html"><span class="hs-identifier">GHC.Types.Id.Info</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html"><span class="hs-identifier">GHC.Types.Unique.Supply</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Substitutions}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span class="hs-comment">-- | A substitution environment, containing 'Id', 'TyVar', and 'CoVar'</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- substitutions.</span><span>
</span><span id="line-80"></span><span class="hs-comment">--</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- Some invariants apply to how you use the substitution:</span><span>
</span><span id="line-82"></span><span class="hs-comment">--</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- 1. Note [The substitution invariant] in &quot;GHC.Core.TyCo.Subst&quot;</span><span>
</span><span id="line-84"></span><span class="hs-comment">--</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- 2. Note [Substitutions apply only once] in &quot;GHC.Core.TyCo.Subst&quot;</span><span>
</span><span id="line-86"></span><span class="hs-keyword">data</span><span> </span><span id="Subst"><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span></span><span>
</span><span id="line-87"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="Subst"><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>  </span><span class="hs-comment">-- Variables in scope (both Ids and TyVars) /after/</span><span>
</span><span id="line-88"></span><span>                      </span><span class="hs-comment">-- applying the substitution</span><span>
</span><span id="line-89"></span><span>          </span><span class="annot"><a href="GHC.Core.Subst.html#IdSubstEnv"><span class="hs-identifier hs-type">IdSubstEnv</span></a></span><span>  </span><span class="hs-comment">-- Substitution from NcIds to CoreExprs</span><span>
</span><span id="line-90"></span><span>          </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>  </span><span class="hs-comment">-- Substitution from TyVars to Types</span><span>
</span><span id="line-91"></span><span>          </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>  </span><span class="hs-comment">-- Substitution from CoVars to Coercions</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span>        </span><span class="hs-comment">-- INVARIANT 1: See TyCoSubst Note [The substitution invariant]</span><span>
</span><span id="line-94"></span><span>        </span><span class="hs-comment">-- This is what lets us deal with name capture properly</span><span>
</span><span id="line-95"></span><span>        </span><span class="hs-comment">-- It's a hard invariant to check...</span><span>
</span><span id="line-96"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-97"></span><span>        </span><span class="hs-comment">-- INVARIANT 2: The substitution is apply-once; see Note [Apply once] with</span><span>
</span><span id="line-98"></span><span>        </span><span class="hs-comment">--              Types.TvSubstEnv</span><span>
</span><span id="line-99"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-100"></span><span>        </span><span class="hs-comment">-- INVARIANT 3: See Note [Extending the Subst]</span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span class="hs-comment">{-
Note [Extending the Subst]
~~~~~~~~~~~~~~~~~~~~~~~~~~
For a core Subst, which binds Ids as well, we make a different choice for Ids
than we do for TyVars.

For TyVars, see Note [Extending the TCvSubst] in GHC.Core.TyCo.Subst.

For Ids, we have a different invariant
        The IdSubstEnv is extended *only* when the Unique on an Id changes
        Otherwise, we just extend the InScopeSet

In consequence:

* If all subst envs are empty, substExpr would be a
  no-op, so substExprSC (&quot;short cut&quot;) does nothing.

  However, substExpr still goes ahead and substitutes.  Reason: we may
  want to replace existing Ids with new ones from the in-scope set, to
  avoid space leaks.

* In substIdBndr, we extend the IdSubstEnv only when the unique changes

* If the CvSubstEnv, TvSubstEnv and IdSubstEnv are all empty,
  substExpr does nothing (Note that the above rule for substIdBndr
  maintains this property.  If the incoming envts are both empty, then
  substituting the type and IdInfo can't change anything.)

* In lookupIdSubst, we *must* look up the Id in the in-scope set, because
  it may contain non-trivial changes.  Example:
        (/\a. \x:a. ...x...) Int
  We extend the TvSubstEnv with [a |-&gt; Int]; but x's unique does not change
  so we only extend the in-scope set.  Then we must look up in the in-scope
  set when we find the occurrence of x.

* The requirement to look up the Id in the in-scope set means that we
  must NOT take no-op short cut when the IdSubst is empty.
  We must still look up every Id in the in-scope set.

* (However, we don't need to do so for expressions found in the IdSubst
  itself, whose range is assumed to be correct wrt the in-scope set.)

Why do we make a different choice for the IdSubstEnv than the
TvSubstEnv and CvSubstEnv?

* For Ids, we change the IdInfo all the time (e.g. deleting the
  unfolding), and adding it back later, so using the TyVar convention
  would entail extending the substitution almost all the time

* The simplifier wants to look up in the in-scope set anyway, in case it
  can see a better unfolding from an enclosing case expression

* For TyVars, only coercion variables can possibly change, and they are
  easy to spot
-}</span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="hs-comment">-- | An environment for substituting for 'Id's</span><span>
</span><span id="line-159"></span><span class="hs-keyword">type</span><span> </span><span id="IdSubstEnv"><span class="annot"><a href="GHC.Core.Subst.html#IdSubstEnv"><span class="hs-identifier hs-var">IdSubstEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>   </span><span class="hs-comment">-- Domain is NcIds, i.e. not coercions</span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span class="hs-comment">----------------------------</span><span>
</span><span id="line-162"></span><span class="annot"><a href="GHC.Core.Subst.html#isEmptySubst"><span class="hs-identifier hs-type">isEmptySubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-163"></span><span id="isEmptySubst"><span class="annot"><span class="annottext">isEmptySubst :: Subst -&gt; Bool
</span><a href="GHC.Core.Subst.html#isEmptySubst"><span class="hs-identifier hs-var hs-var">isEmptySubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680865880"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865880"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span id="local-6989586621680865879"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865879"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span id="local-6989586621680865878"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865878"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865880"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865879"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865878"><span class="hs-identifier hs-var">cv_env</span></a></span><span>
</span><span id="line-165"></span><span>
</span><span id="line-166"></span><span class="annot"><a href="GHC.Core.Subst.html#emptySubst"><span class="hs-identifier hs-type">emptySubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-167"></span><span id="emptySubst"><span class="annot"><span class="annottext">emptySubst :: Subst
</span><a href="GHC.Core.Subst.html#emptySubst"><span class="hs-identifier hs-var hs-var">emptySubst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="GHC.Types.Var.Env.html#emptyInScopeSet"><span class="hs-identifier hs-var">emptyInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span class="annot"><a href="GHC.Core.Subst.html#mkEmptySubst"><span class="hs-identifier hs-type">mkEmptySubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-170"></span><span id="mkEmptySubst"><span class="annot"><span class="annottext">mkEmptySubst :: InScopeSet -&gt; Subst
</span><a href="GHC.Core.Subst.html#mkEmptySubst"><span class="hs-identifier hs-var hs-var">mkEmptySubst</span></a></span></span><span> </span><span id="local-6989586621680865873"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865873"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865873"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span class="annot"><a href="GHC.Core.Subst.html#mkSubst"><span class="hs-identifier hs-type">mkSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#IdSubstEnv"><span class="hs-identifier hs-type">IdSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-173"></span><span id="mkSubst"><span class="annot"><span class="annottext">mkSubst :: InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; IdSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#mkSubst"><span class="hs-identifier hs-var hs-var">mkSubst</span></a></span></span><span> </span><span id="local-6989586621680865872"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865872"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865871"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865871"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865870"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865870"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span id="local-6989586621680865869"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865869"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865872"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865869"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865871"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865870"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-174"></span><span>
</span><span id="line-175"></span><span class="hs-comment">-- | Find the in-scope set: see &quot;GHC.Core.TyCo.Subst&quot; Note [The substitution invariant]</span><span>
</span><span id="line-176"></span><span class="annot"><a href="GHC.Core.Subst.html#substInScope"><span class="hs-identifier hs-type">substInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>
</span><span id="line-177"></span><span id="substInScope"><span class="annot"><span class="annottext">substInScope :: Subst -&gt; InScopeSet
</span><a href="GHC.Core.Subst.html#substInScope"><span class="hs-identifier hs-var hs-var">substInScope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865868"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865868"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865868"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span class="hs-comment">-- | Remove all substitutions for 'Id's and 'Var's that might have been built up</span><span>
</span><span id="line-180"></span><span class="hs-comment">-- while preserving the in-scope set</span><span>
</span><span id="line-181"></span><span class="annot"><a href="GHC.Core.Subst.html#zapSubstEnv"><span class="hs-identifier hs-type">zapSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-182"></span><span id="zapSubstEnv"><span class="annot"><span class="annottext">zapSubstEnv :: Subst -&gt; Subst
</span><a href="GHC.Core.Subst.html#zapSubstEnv"><span class="hs-identifier hs-var hs-var">zapSubstEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865867"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865867"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865867"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-183"></span><span>
</span><span id="line-184"></span><span class="hs-comment">-- | Add a substitution for an 'Id' to the 'Subst': you must ensure that the in-scope set is</span><span>
</span><span id="line-185"></span><span class="hs-comment">-- such that TyCoSubst Note [The substitution invariant]</span><span>
</span><span id="line-186"></span><span class="hs-comment">-- holds after extending the substitution like this</span><span>
</span><span id="line-187"></span><span class="annot"><a href="GHC.Core.Subst.html#extendIdSubst"><span class="hs-identifier hs-type">extendIdSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-188"></span><span class="hs-comment">-- ToDo: add an ASSERT that fvs(subst-result) is already in the in-scope set</span><span>
</span><span id="line-189"></span><span id="extendIdSubst"><span class="annot"><span class="annottext">extendIdSubst :: Subst -&gt; Id -&gt; CoreExpr -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendIdSubst"><span class="hs-identifier hs-var hs-var">extendIdSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865866"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865866"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865865"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865865"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865864"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865864"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865863"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865863"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865862"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865862"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621680865861"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865861"><span class="hs-identifier hs-var">r</span></a></span></span><span>
</span><span id="line-190"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isNonCoVarId</span><span> </span><span class="hs-identifier">v</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-191"></span><span>    </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865866"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv -&gt; Id -&gt; CoreExpr -&gt; IdSubstEnv
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865865"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865862"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865861"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865864"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865863"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-192"></span><span>
</span><span id="line-193"></span><span class="hs-comment">-- | Adds multiple 'Id' substitutions to the 'Subst': see also 'extendIdSubst'</span><span>
</span><span id="line-194"></span><span class="annot"><a href="GHC.Core.Subst.html#extendIdSubstList"><span class="hs-identifier hs-type">extendIdSubstList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-195"></span><span id="extendIdSubstList"><span class="annot"><span class="annottext">extendIdSubstList :: Subst -&gt; [(Id, CoreExpr)] -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendIdSubstList"><span class="hs-identifier hs-var hs-var">extendIdSubstList</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865853"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865853"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865852"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865852"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865851"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865851"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865850"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865850"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865849"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865849"><span class="hs-identifier hs-var">prs</span></a></span></span><span>
</span><span id="line-196"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">all</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isNonCoVarId</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">fst</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">prs</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span>    </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865853"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv -&gt; [(Id, CoreExpr)] -&gt; IdSubstEnv
forall a. VarEnv a -&gt; [(Id, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnvList"><span class="hs-identifier hs-var">extendVarEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865852"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865849"><span class="hs-identifier hs-var">prs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865851"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865850"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="hs-comment">-- | Add a substitution for a 'TyVar' to the 'Subst'</span><span>
</span><span id="line-200"></span><span class="hs-comment">-- The 'TyVar' *must* be a real TyVar, and not a CoVar</span><span>
</span><span id="line-201"></span><span class="hs-comment">-- You must ensure that the in-scope set is such that</span><span>
</span><span id="line-202"></span><span class="hs-comment">-- &quot;GHC.Core.TyCo.Subst&quot; Note [The substitution invariant] holds</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- after extending the substitution like this.</span><span>
</span><span id="line-204"></span><span class="annot"><a href="GHC.Core.Subst.html#extendTvSubst"><span class="hs-identifier hs-type">extendTvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-205"></span><span id="extendTvSubst"><span class="annot"><span class="annottext">extendTvSubst :: Subst -&gt; Id -&gt; Type -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendTvSubst"><span class="hs-identifier hs-var hs-var">extendTvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865843"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865843"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865842"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865842"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865841"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865841"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865840"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865840"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865839"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865839"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680865838"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865838"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-206"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">tv</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-207"></span><span>    </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865843"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865842"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Id -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865841"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865839"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865838"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865840"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-208"></span><span>
</span><span id="line-209"></span><span class="hs-comment">-- | Adds multiple 'TyVar' substitutions to the 'Subst': see also 'extendTvSubst'</span><span>
</span><span id="line-210"></span><span class="annot"><a href="GHC.Core.Subst.html#extendTvSubstList"><span class="hs-identifier hs-type">extendTvSubstList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-211"></span><span id="extendTvSubstList"><span class="annot"><span class="annottext">extendTvSubstList :: Subst -&gt; [(Id, Type)] -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendTvSubstList"><span class="hs-identifier hs-var hs-var">extendTvSubstList</span></a></span></span><span> </span><span id="local-6989586621680865836"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865836"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865835"><span class="annot"><span class="annottext">[(Id, Type)]
</span><a href="#local-6989586621680865835"><span class="hs-identifier hs-var">vrs</span></a></span></span><span>
</span><span id="line-212"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Subst -&gt; (Id, Type) -&gt; Subst) -&gt; Subst -&gt; [(Id, Type)] -&gt; Subst
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">Subst -&gt; (Id, Type) -&gt; Subst
</span><a href="#local-6989586621680865833"><span class="hs-identifier hs-var">extend</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865836"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Type)]
</span><a href="#local-6989586621680865835"><span class="hs-identifier hs-var">vrs</span></a></span><span>
</span><span id="line-213"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-214"></span><span>    </span><span id="local-6989586621680865833"><span class="annot"><span class="annottext">extend :: Subst -&gt; (Id, Type) -&gt; Subst
</span><a href="#local-6989586621680865833"><span class="hs-identifier hs-var hs-var">extend</span></a></span></span><span> </span><span id="local-6989586621680865832"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865832"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680865831"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865831"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865830"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865830"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Type -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendTvSubst"><span class="hs-identifier hs-var">extendTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865832"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865831"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865830"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-215"></span><span>
</span><span id="line-216"></span><span class="hs-comment">-- | Add a substitution from a 'CoVar' to a 'Coercion' to the 'Subst':</span><span>
</span><span id="line-217"></span><span class="hs-comment">-- you must ensure that the in-scope set satisfies</span><span>
</span><span id="line-218"></span><span class="hs-comment">-- &quot;GHC.Core.TyCo.Subst&quot; Note [The substitution invariant]</span><span>
</span><span id="line-219"></span><span class="hs-comment">-- after extending the substitution like this</span><span>
</span><span id="line-220"></span><span class="annot"><a href="GHC.Core.Subst.html#extendCvSubst"><span class="hs-identifier hs-type">extendCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-221"></span><span id="extendCvSubst"><span class="annot"><span class="annottext">extendCvSubst :: Subst -&gt; Id -&gt; Coercion -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendCvSubst"><span class="hs-identifier hs-var hs-var">extendCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865828"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865828"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865827"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865827"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865826"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865826"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865825"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865825"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865824"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865824"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621680865823"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865823"><span class="hs-identifier hs-var">r</span></a></span></span><span>
</span><span id="line-222"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-223"></span><span>    </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865828"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865827"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865826"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Id -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865825"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865824"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865823"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-224"></span><span>
</span><span id="line-225"></span><span class="hs-comment">-- | Add a substitution appropriate to the thing being substituted</span><span>
</span><span id="line-226"></span><span class="hs-comment">--   (whether an expression, type, or coercion). See also</span><span>
</span><span id="line-227"></span><span class="hs-comment">--   'extendIdSubst', 'extendTvSubst', 'extendCvSubst'</span><span>
</span><span id="line-228"></span><span class="annot"><a href="GHC.Core.Subst.html#extendSubst"><span class="hs-identifier hs-type">extendSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreArg"><span class="hs-identifier hs-type">CoreArg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-229"></span><span id="extendSubst"><span class="annot"><span class="annottext">extendSubst :: Subst -&gt; Id -&gt; CoreExpr -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubst"><span class="hs-identifier hs-var hs-var">extendSubst</span></a></span></span><span> </span><span id="local-6989586621680865819"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865819"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865818"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865818"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span id="local-6989586621680865817"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865817"><span class="hs-identifier hs-var">arg</span></a></span></span><span>
</span><span id="line-230"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865817"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-231"></span><span>      </span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span id="local-6989586621680865815"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865815"><span class="hs-identifier hs-var">ty</span></a></span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">extendTvSubst</span><span> </span><span class="hs-identifier">subst</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-identifier">ty</span><span>
</span><span id="line-232"></span><span>      </span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span id="local-6989586621680865813"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865813"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">extendCvSubst</span><span> </span><span class="hs-identifier">subst</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-identifier">co</span><span>
</span><span id="line-233"></span><span>      </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isId</span><span>    </span><span class="hs-identifier">var</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">extendIdSubst</span><span> </span><span class="hs-identifier">subst</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-identifier">arg</span><span>
</span><span id="line-234"></span><span>
</span><span id="line-235"></span><span class="annot"><a href="GHC.Core.Subst.html#extendSubstWithVar"><span class="hs-identifier hs-type">extendSubstWithVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-236"></span><span id="extendSubstWithVar"><span class="annot"><span class="annottext">extendSubstWithVar :: Subst -&gt; Id -&gt; Id -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubstWithVar"><span class="hs-identifier hs-var hs-var">extendSubstWithVar</span></a></span></span><span> </span><span id="local-6989586621680865811"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865811"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865810"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865810"><span class="hs-identifier hs-var">v1</span></a></span></span><span> </span><span id="local-6989586621680865809"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865809"><span class="hs-identifier hs-var">v2</span></a></span></span><span>
</span><span id="line-237"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865810"><span class="hs-identifier hs-var">v1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">v2</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">extendTvSubst</span><span> </span><span class="hs-identifier">subst</span><span> </span><span class="hs-identifier">v1</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">mkTyVarTy</span><span> </span><span class="hs-identifier">v2</span><span class="hs-special">)</span><span>
</span><span id="line-238"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865810"><span class="hs-identifier hs-var">v1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">v2</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">extendCvSubst</span><span> </span><span class="hs-identifier">subst</span><span> </span><span class="hs-identifier">v1</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">mkCoVarCo</span><span> </span><span class="hs-identifier">v2</span><span class="hs-special">)</span><span>
</span><span id="line-239"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isId</span><span>    </span><span class="hs-identifier">v2</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">extendIdSubst</span><span> </span><span class="hs-identifier">subst</span><span> </span><span class="hs-identifier">v1</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Var</span><span> </span><span class="hs-identifier">v2</span><span class="hs-special">)</span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span class="hs-comment">-- | Add a substitution as appropriate to each of the terms being</span><span>
</span><span id="line-242"></span><span class="hs-comment">--   substituted (whether expressions, types, or coercions). See also</span><span>
</span><span id="line-243"></span><span class="hs-comment">--   'extendSubst'.</span><span>
</span><span id="line-244"></span><span class="annot"><a href="GHC.Core.Subst.html#extendSubstList"><span class="hs-identifier hs-type">extendSubstList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreArg"><span class="hs-identifier hs-type">CoreArg</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-245"></span><span id="extendSubstList"><span class="annot"><span class="annottext">extendSubstList :: Subst -&gt; [(Id, CoreExpr)] -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubstList"><span class="hs-identifier hs-var hs-var">extendSubstList</span></a></span></span><span> </span><span id="local-6989586621680865805"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865805"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865805"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-246"></span><span class="annot"><a href="GHC.Core.Subst.html#extendSubstList"><span class="hs-identifier hs-var">extendSubstList</span></a></span><span> </span><span id="local-6989586621680865804"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865804"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621680865803"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865803"><span class="hs-identifier hs-var">var</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680865802"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865802"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680865801"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865801"><span class="hs-identifier hs-var">prs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [(Id, CoreExpr)] -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubstList"><span class="hs-identifier hs-var">extendSubstList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; CoreExpr -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubst"><span class="hs-identifier hs-var">extendSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865804"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865803"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865802"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865801"><span class="hs-identifier hs-var">prs</span></a></span><span>
</span><span id="line-247"></span><span>
</span><span id="line-248"></span><span class="hs-comment">-- | Find the substitution for an 'Id' in the 'Subst'</span><span>
</span><span id="line-249"></span><span class="annot"><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-type">lookupIdSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-250"></span><span id="lookupIdSubst"><span class="annot"><span class="annottext">lookupIdSubst :: HasDebugCallStack =&gt; Subst -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-var hs-var">lookupIdSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865794"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865794"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865793"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865793"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865792"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865792"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-251"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalId"><span class="hs-identifier hs-var">isLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865792"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865792"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-252"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680865790"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865790"><span class="hs-identifier hs-var">e</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IdSubstEnv -&gt; Id -&gt; Maybe CoreExpr
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865793"><span class="hs-identifier hs-var">ids</span></a></span><span>       </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865792"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865790"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-253"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680865788"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865788"><span class="hs-identifier hs-var">v'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; Maybe Id
</span><a href="GHC.Types.Var.Env.html#lookupInScope"><span class="hs-identifier hs-var">lookupInScope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865794"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865792"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865788"><span class="hs-identifier hs-var">v'</span></a></span><span>
</span><span id="line-254"></span><span>        </span><span class="hs-comment">-- Vital! See Note [Extending the Subst]</span><span>
</span><span id="line-255"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">True</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;GHC.Core.Subst.lookupIdSubst&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">v</span><span>
</span><span id="line-256"></span><span>                            </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">in_scope</span><span class="hs-special">)</span><span>
</span><span id="line-257"></span><span>                </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865792"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-258"></span><span>
</span><span id="line-259"></span><span class="hs-comment">-- | Find the substitution for a 'TyVar' in the 'Subst'</span><span>
</span><span id="line-260"></span><span class="annot"><a href="GHC.Core.Subst.html#lookupTCvSubst"><span class="hs-identifier hs-type">lookupTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-261"></span><span id="lookupTCvSubst"><span class="annot"><span class="annottext">lookupTCvSubst :: Subst -&gt; Id -&gt; Type
</span><a href="GHC.Core.Subst.html#lookupTCvSubst"><span class="hs-identifier hs-var hs-var">lookupTCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680865783"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865783"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865782"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865782"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865781"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865781"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-262"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865781"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-263"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Id -&gt; Maybe Type
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865783"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865781"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Type -&gt; Type -&gt; Type
forall a. Maybe a -&gt; a -&gt; a
</span><a href="GHC.Data.Maybe.html#orElse"><span class="hs-operator hs-var">`orElse`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">Type.mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865781"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-264"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-265"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCoercionTy"><span class="hs-identifier hs-var">mkCoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Type) -&gt; Coercion -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Id -&gt; Maybe Coercion
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865782"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865781"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Coercion -&gt; Coercion -&gt; Coercion
forall a. Maybe a -&gt; a -&gt; a
</span><a href="GHC.Data.Maybe.html#orElse"><span class="hs-operator hs-var">`orElse`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier hs-var">mkCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865781"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-266"></span><span>
</span><span id="line-267"></span><span class="annot"><a href="GHC.Core.Subst.html#delBndr"><span class="hs-identifier hs-type">delBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-268"></span><span id="delBndr"><span class="annot"><span class="annottext">delBndr :: Subst -&gt; Id -&gt; Subst
</span><a href="GHC.Core.Subst.html#delBndr"><span class="hs-identifier hs-var hs-var">delBndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865778"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865778"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865777"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865777"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865776"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865776"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865775"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865775"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865774"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865774"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-269"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865774"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865778"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865777"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865776"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Id -&gt; CvSubstEnv
forall a. VarEnv a -&gt; Id -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865775"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865774"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-270"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865774"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865778"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865777"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Id -&gt; TvSubstEnv
forall a. VarEnv a -&gt; Id -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865776"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865774"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865775"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-271"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865778"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv -&gt; Id -&gt; IdSubstEnv
forall a. VarEnv a -&gt; Id -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865777"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865774"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865776"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865775"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-272"></span><span>
</span><span id="line-273"></span><span class="annot"><a href="GHC.Core.Subst.html#delBndrs"><span class="hs-identifier hs-type">delBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-274"></span><span id="delBndrs"><span class="annot"><span class="annottext">delBndrs :: Subst -&gt; [Id] -&gt; Subst
</span><a href="GHC.Core.Subst.html#delBndrs"><span class="hs-identifier hs-var hs-var">delBndrs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865772"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865772"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865771"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865771"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865770"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865770"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865769"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865769"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865768"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865768"><span class="hs-identifier hs-var">vs</span></a></span></span><span>
</span><span id="line-275"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865772"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv -&gt; [Id] -&gt; IdSubstEnv
forall a. VarEnv a -&gt; [Id] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-identifier hs-var">delVarEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865771"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865768"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; [Id] -&gt; TvSubstEnv
forall a. VarEnv a -&gt; [Id] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-identifier hs-var">delVarEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865770"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865768"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv -&gt; [Id] -&gt; CvSubstEnv
forall a. VarEnv a -&gt; [Id] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-identifier hs-var">delVarEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865769"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865768"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-276"></span><span>      </span><span class="hs-comment">-- Easiest thing is just delete all from all!</span><span>
</span><span id="line-277"></span><span>
</span><span id="line-278"></span><span class="hs-comment">-- | Simultaneously substitute for a bunch of variables</span><span>
</span><span id="line-279"></span><span class="hs-comment">--   No left-right shadowing</span><span>
</span><span id="line-280"></span><span class="hs-comment">--   ie the substitution for   (\x \y. e) a1 a2</span><span>
</span><span id="line-281"></span><span class="hs-comment">--      so neither x nor y scope over a1 a2</span><span>
</span><span id="line-282"></span><span class="annot"><a href="GHC.Core.Subst.html#mkOpenSubst"><span class="hs-identifier hs-type">mkOpenSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreArg"><span class="hs-identifier hs-type">CoreArg</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-283"></span><span id="mkOpenSubst"><span class="annot"><span class="annottext">mkOpenSubst :: InScopeSet -&gt; [(Id, CoreExpr)] -&gt; Subst
</span><a href="GHC.Core.Subst.html#mkOpenSubst"><span class="hs-identifier hs-var hs-var">mkOpenSubst</span></a></span></span><span> </span><span id="local-6989586621680865766"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865766"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865765"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865765"><span class="hs-identifier hs-var">pairs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865766"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-284"></span><span>                                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; IdSubstEnv
forall a. [(Id, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865763"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865762"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680865763"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865763"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865762"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865762"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865765"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865763"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-285"></span><span>                                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, Type)] -&gt; TvSubstEnv
forall a. [(Id, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865761"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865760"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680865761"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865761"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span id="local-6989586621680865760"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865760"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865765"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-286"></span><span>                                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, Coercion)] -&gt; CvSubstEnv
forall a. [(Id, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865759"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865758"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680865759"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865759"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span id="local-6989586621680865758"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865758"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865765"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-287"></span><span>
</span><span id="line-288"></span><span class="hs-comment">------------------------------</span><span>
</span><span id="line-289"></span><span class="annot"><a href="GHC.Core.Subst.html#isInScope"><span class="hs-identifier hs-type">isInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-290"></span><span id="isInScope"><span class="annot"><span class="annottext">isInScope :: Id -&gt; Subst -&gt; Bool
</span><a href="GHC.Core.Subst.html#isInScope"><span class="hs-identifier hs-var hs-var">isInScope</span></a></span></span><span> </span><span id="local-6989586621680865757"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865757"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865756"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865756"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865757"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; InScopeSet -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemInScopeSet"><span class="hs-operator hs-var">`elemInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865756"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-291"></span><span>
</span><span id="line-292"></span><span class="hs-comment">-- | Add the 'Var' to the in-scope set, but do not remove</span><span>
</span><span id="line-293"></span><span class="hs-comment">-- any existing substitutions for it</span><span>
</span><span id="line-294"></span><span class="annot"><a href="GHC.Core.Subst.html#addInScopeSet"><span class="hs-identifier hs-type">addInScopeSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-295"></span><span id="addInScopeSet"><span class="annot"><span class="annottext">addInScopeSet :: Subst -&gt; VarSet -&gt; Subst
</span><a href="GHC.Core.Subst.html#addInScopeSet"><span class="hs-identifier hs-var hs-var">addInScopeSet</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865754"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865754"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865753"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865753"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865752"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865752"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865751"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865751"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865750"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680865750"><span class="hs-identifier hs-var">vs</span></a></span></span><span>
</span><span id="line-296"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865754"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetSet"><span class="hs-operator hs-var">`extendInScopeSetSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680865750"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865753"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865752"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865751"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-297"></span><span>
</span><span id="line-298"></span><span class="hs-comment">-- | Add the 'Var' to the in-scope set: as a side effect,</span><span>
</span><span id="line-299"></span><span class="hs-comment">-- and remove any existing substitutions for it</span><span>
</span><span id="line-300"></span><span class="annot"><a href="GHC.Core.Subst.html#extendInScope"><span class="hs-identifier hs-type">extendInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-301"></span><span id="extendInScope"><span class="annot"><span class="annottext">extendInScope :: Subst -&gt; Id -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendInScope"><span class="hs-identifier hs-var hs-var">extendInScope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865748"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865748"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865747"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865747"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865746"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865746"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865745"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865745"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865744"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865744"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-302"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865748"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865744"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-303"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865747"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv -&gt; Id -&gt; IdSubstEnv
forall a. VarEnv a -&gt; Id -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-operator hs-var">`delVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865744"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865746"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Id -&gt; TvSubstEnv
forall a. VarEnv a -&gt; Id -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-operator hs-var">`delVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865744"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865745"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Id -&gt; CvSubstEnv
forall a. VarEnv a -&gt; Id -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-operator hs-var">`delVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865744"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-304"></span><span>
</span><span id="line-305"></span><span class="hs-comment">-- | Add the 'Var's to the in-scope set: see also 'extendInScope'</span><span>
</span><span id="line-306"></span><span class="annot"><a href="GHC.Core.Subst.html#extendInScopeList"><span class="hs-identifier hs-type">extendInScopeList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-307"></span><span id="extendInScopeList"><span class="annot"><span class="annottext">extendInScopeList :: Subst -&gt; [Id] -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendInScopeList"><span class="hs-identifier hs-var hs-var">extendInScopeList</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865742"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865742"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865741"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865741"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865740"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865740"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865739"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865739"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865738"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865738"><span class="hs-identifier hs-var">vs</span></a></span></span><span>
</span><span id="line-308"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865742"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; [Id] -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetList"><span class="hs-operator hs-var">`extendInScopeSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865738"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-309"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865741"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv -&gt; [Id] -&gt; IdSubstEnv
forall a. VarEnv a -&gt; [Id] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-operator hs-var">`delVarEnvList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865738"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865740"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; [Id] -&gt; TvSubstEnv
forall a. VarEnv a -&gt; [Id] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-operator hs-var">`delVarEnvList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865738"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865739"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; [Id] -&gt; CvSubstEnv
forall a. VarEnv a -&gt; [Id] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-operator hs-var">`delVarEnvList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865738"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-310"></span><span>
</span><span id="line-311"></span><span class="hs-comment">-- | Optimized version of 'extendInScopeList' that can be used if you are certain</span><span>
</span><span id="line-312"></span><span class="hs-comment">-- all the things being added are 'Id's and hence none are 'TyVar's or 'CoVar's</span><span>
</span><span id="line-313"></span><span class="annot"><a href="GHC.Core.Subst.html#extendInScopeIds"><span class="hs-identifier hs-type">extendInScopeIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-314"></span><span id="extendInScopeIds"><span class="annot"><span class="annottext">extendInScopeIds :: Subst -&gt; [Id] -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendInScopeIds"><span class="hs-identifier hs-var hs-var">extendInScopeIds</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865736"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865736"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865735"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865735"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865734"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865734"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865733"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865733"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865732"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865732"><span class="hs-identifier hs-var">vs</span></a></span></span><span>
</span><span id="line-315"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865736"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; [Id] -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetList"><span class="hs-operator hs-var">`extendInScopeSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865732"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-316"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865735"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv -&gt; [Id] -&gt; IdSubstEnv
forall a. VarEnv a -&gt; [Id] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-operator hs-var">`delVarEnvList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865732"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865734"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865733"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-317"></span><span>
</span><span id="line-318"></span><span class="annot"><a href="GHC.Core.Subst.html#setInScope"><span class="hs-identifier hs-type">setInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-319"></span><span id="setInScope"><span class="annot"><span class="annottext">setInScope :: Subst -&gt; InScopeSet -&gt; Subst
</span><a href="GHC.Core.Subst.html#setInScope"><span class="hs-identifier hs-var hs-var">setInScope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680865731"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865731"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865730"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865730"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865729"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865729"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865728"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865728"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865728"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865731"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865730"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865729"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-320"></span><span>
</span><span id="line-321"></span><span class="hs-comment">-- Pretty printing, for debugging only</span><span>
</span><span id="line-322"></span><span>
</span><span id="line-323"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680865725"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-324"></span><span>  </span><span id="local-6989586621680865715"><span class="annot"><span class="annottext">ppr :: Subst -&gt; SDoc
</span><a href="#local-6989586621680865715"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865714"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865714"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865713"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865713"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680865712"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865712"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865711"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865711"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-325"></span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&lt;InScope =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621680865710"><span class="hs-identifier hs-var">in_scope_doc</span></a></span><span>
</span><span id="line-326"></span><span>        </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; IdSubst   =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865713"><span class="hs-identifier hs-var">ids</span></a></span><span>
</span><span id="line-327"></span><span>        </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; TvSubst   =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865712"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-328"></span><span>        </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; CvSubst   =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865711"><span class="hs-identifier hs-var">cvs</span></a></span><span>
</span><span id="line-329"></span><span>         </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'&gt;'</span></span><span>
</span><span id="line-330"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-331"></span><span>    </span><span id="local-6989586621680865710"><span class="annot"><span class="annottext">in_scope_doc :: SDoc
</span><a href="#local-6989586621680865710"><span class="hs-identifier hs-var hs-var">in_scope_doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; ([Id] -&gt; SDoc) -&gt; SDoc
</span><a href="GHC.Types.Var.Set.html#pprVarSet"><span class="hs-identifier hs-var">pprVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; VarSet
</span><a href="GHC.Types.Var.Env.html#getInScopeVars"><span class="hs-identifier hs-var">getInScopeVars</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865714"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; ([Id] -&gt; SDoc) -&gt; [Id] -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#fsep"><span class="hs-identifier hs-var">fsep</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; ([Id] -&gt; [SDoc]) -&gt; [Id] -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; SDoc) -&gt; [Id] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-332"></span><span>
</span><span id="line-333"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
        Substituting expressions
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-340"></span><span>
</span><span id="line-341"></span><span class="annot"><a href="GHC.Core.Subst.html#substExprSC"><span class="hs-identifier hs-type">substExprSC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-342"></span><span class="hs-comment">-- Just like substExpr, but a no-op if the substitution is empty</span><span>
</span><span id="line-343"></span><span id="substExprSC"><span class="annot"><span class="annottext">substExprSC :: HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExprSC"><span class="hs-identifier hs-var hs-var">substExprSC</span></a></span></span><span> </span><span id="local-6989586621680865700"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865700"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865699"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865699"><span class="hs-identifier hs-var">orig_expr</span></a></span></span><span>
</span><span id="line-344"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Bool
</span><a href="GHC.Core.Subst.html#isEmptySubst"><span class="hs-identifier hs-var">isEmptySubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865700"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865699"><span class="hs-identifier hs-var">orig_expr</span></a></span><span>
</span><span id="line-345"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;enter subst-expr&quot; (doc $$ ppr orig_expr) $</span><span>
</span><span id="line-346"></span><span>                         </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865700"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865699"><span class="hs-identifier hs-var">orig_expr</span></a></span><span>
</span><span id="line-347"></span><span>
</span><span id="line-348"></span><span class="hs-comment">-- | substExpr applies a substitution to an entire 'CoreExpr'. Remember,</span><span>
</span><span id="line-349"></span><span class="hs-comment">-- you may only apply the substitution /once/:</span><span>
</span><span id="line-350"></span><span class="hs-comment">-- See Note [Substitutions apply only once] in &quot;GHC.Core.TyCo.Subst&quot;</span><span>
</span><span id="line-351"></span><span class="hs-comment">--</span><span>
</span><span id="line-352"></span><span class="hs-comment">-- Do *not* attempt to short-cut in the case of an empty substitution!</span><span>
</span><span id="line-353"></span><span class="hs-comment">-- See Note [Extending the Subst]</span><span>
</span><span id="line-354"></span><span class="annot"><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-type">substExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-355"></span><span>   </span><span class="hs-comment">-- HasDebugCallStack so we can track failures in lookupIdSubst</span><span>
</span><span id="line-356"></span><span id="substExpr"><span class="annot"><span class="annottext">substExpr :: HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var hs-var">substExpr</span></a></span></span><span> </span><span id="local-6989586621680865697"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865696"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865696"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-357"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865696"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-358"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-359"></span><span>    </span><span id="local-6989586621680865695"><span class="annot"><span class="annottext">go :: CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680865695"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680865687"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865687"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Id -&gt; CoreExpr
Subst -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-var">lookupIdSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865687"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-360"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span id="local-6989586621680865686"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865686"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CoreExpr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865686"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span id="local-6989586621680865685"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865685"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; CoreExpr
forall b. Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-var">Coercion</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865685"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-362"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-type">Lit</span></a></span><span> </span><span id="local-6989586621680865683"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680865683"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; CoreExpr
forall b. Literal -&gt; Expr b
</span><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-var">Lit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680865683"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-363"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680865681"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865681"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621680865680"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865680"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865681"><span class="hs-identifier hs-var">fun</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865680"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-364"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680865678"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680865678"><span class="hs-identifier hs-var">tickish</span></a></span></span><span> </span><span id="local-6989586621680865677"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865677"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tickish Id -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Utils.html#mkTick"><span class="hs-identifier hs-var">mkTick</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Tickish Id -&gt; Tickish Id
</span><a href="GHC.Core.Subst.html#substTickish"><span class="hs-identifier hs-var">substTickish</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680865678"><span class="hs-identifier hs-var">tickish</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865677"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-365"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680865674"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865674"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680865673"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865673"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Coercion -&gt; CoreExpr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865674"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865673"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-366"></span><span>       </span><span class="hs-comment">-- Do not optimise even identity coercions</span><span>
</span><span id="line-367"></span><span>       </span><span class="hs-comment">-- Reason: substitution applies to the LHS of RULES, and</span><span>
</span><span id="line-368"></span><span>       </span><span class="hs-comment">--         if you &quot;optimise&quot; an identity coercion, you may</span><span>
</span><span id="line-369"></span><span>       </span><span class="hs-comment">--         lose a binder. We optimise the LHS of rules at</span><span>
</span><span id="line-370"></span><span>       </span><span class="hs-comment">--         construction time</span><span>
</span><span id="line-371"></span><span>
</span><span id="line-372"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680865671"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865671"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680865670"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865670"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865669"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865668"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865670"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-373"></span><span>                       </span><span class="hs-keyword">where</span><span>
</span><span id="line-374"></span><span>                         </span><span class="hs-special">(</span><span id="local-6989586621680865668"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865668"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865669"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865669"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865671"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-375"></span><span>
</span><span id="line-376"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span id="local-6989586621680865666"><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680865666"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span id="local-6989586621680865665"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865665"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bind Id -&gt; CoreExpr -&gt; CoreExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680865664"><span class="hs-identifier hs-var">bind'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865663"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865665"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-377"></span><span>                       </span><span class="hs-keyword">where</span><span>
</span><span id="line-378"></span><span>                         </span><span class="hs-special">(</span><span id="local-6989586621680865663"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865663"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865664"><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680865664"><span class="hs-identifier hs-var">bind'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
</span><a href="GHC.Core.Subst.html#substBind"><span class="hs-identifier hs-var">substBind</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680865666"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-379"></span><span>
</span><span id="line-380"></span><span>    </span><span class="annot"><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621680865660"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865660"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680865659"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865659"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680865658"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865658"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680865657"><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680865657"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Id -&gt; Type -&gt; [Alt Id] -&gt; CoreExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680865695"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865660"><span class="hs-identifier hs-var">scrut</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865656"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865658"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Alt Id -&gt; Alt Id) -&gt; [Alt Id] -&gt; [Alt Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Alt Id -&gt; Alt Id
forall {a}. Subst -&gt; (a, [Id], CoreExpr) -&gt; (a, [Id], CoreExpr)
</span><a href="#local-6989586621680865655"><span class="hs-identifier hs-var">go_alt</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865654"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680865657"><span class="hs-identifier hs-var">alts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-381"></span><span>                                 </span><span class="hs-keyword">where</span><span>
</span><span id="line-382"></span><span>                                 </span><span class="hs-special">(</span><span id="local-6989586621680865654"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865654"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865656"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865656"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865659"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-383"></span><span>
</span><span id="line-384"></span><span>    </span><span id="local-6989586621680865655"><span class="annot"><span class="annottext">go_alt :: Subst -&gt; (a, [Id], CoreExpr) -&gt; (a, [Id], CoreExpr)
</span><a href="#local-6989586621680865655"><span class="hs-identifier hs-var hs-var">go_alt</span></a></span></span><span> </span><span id="local-6989586621680865652"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865652"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680865651"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680865651"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865650"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865650"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865649"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865649"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680865651"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865648"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865647"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865649"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-385"></span><span>                                 </span><span class="hs-keyword">where</span><span>
</span><span id="line-386"></span><span>                                   </span><span class="hs-special">(</span><span id="local-6989586621680865647"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865647"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865648"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865648"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865652"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865650"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-387"></span><span>
</span><span id="line-388"></span><span class="hs-comment">-- | Apply a substitution to an entire 'CoreBind', additionally returning an updated 'Subst'</span><span>
</span><span id="line-389"></span><span class="hs-comment">-- that should be used by subsequent substitutions.</span><span>
</span><span id="line-390"></span><span class="annot"><a href="GHC.Core.Subst.html#substBind"><span class="hs-identifier hs-type">substBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substBindSC"><span class="hs-identifier hs-type">substBindSC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-391"></span><span>
</span><span id="line-392"></span><span id="substBindSC"><span class="annot"><span class="annottext">substBindSC :: HasDebugCallStack =&gt; Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
</span><a href="GHC.Core.Subst.html#substBindSC"><span class="hs-identifier hs-var hs-var">substBindSC</span></a></span></span><span> </span><span id="local-6989586621680865643"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865643"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865642"><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680865642"><span class="hs-identifier hs-var">bind</span></a></span></span><span>    </span><span class="hs-comment">-- Short-cut if the substitution is empty</span><span>
</span><span id="line-393"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Bool
</span><a href="GHC.Core.Subst.html#isEmptySubst"><span class="hs-identifier hs-var">isEmptySubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865643"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-394"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
</span><a href="GHC.Core.Subst.html#substBind"><span class="hs-identifier hs-var">substBind</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865643"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680865642"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-395"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-396"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680865642"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-397"></span><span>       </span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680865640"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865640"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680865639"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865639"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865638"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; Bind Id
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865637"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865639"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-398"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-399"></span><span>            </span><span class="hs-special">(</span><span id="local-6989586621680865638"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865638"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865637"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865637"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865643"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865640"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-400"></span><span>       </span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680865635"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865635"><span class="hs-identifier hs-var">pairs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865634"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; Bind Id
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865633"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [CoreExpr] -&gt; [(Id, CoreExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865632"><span class="hs-identifier hs-var">rhss'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-401"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-402"></span><span>            </span><span class="hs-special">(</span><span id="local-6989586621680865631"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865631"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865630"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865630"><span class="hs-identifier hs-var">rhss</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; ([Id], [CoreExpr])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865635"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-403"></span><span>            </span><span class="hs-special">(</span><span id="local-6989586621680865634"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865634"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865633"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865633"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substRecBndrs"><span class="hs-identifier hs-var">substRecBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865643"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865631"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-404"></span><span>            </span><span id="local-6989586621680865632"><span class="annot"><span class="annottext">rhss' :: [CoreExpr]
</span><a href="#local-6989586621680865632"><span class="hs-identifier hs-var hs-var">rhss'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Bool
</span><a href="GHC.Core.Subst.html#isEmptySubst"><span class="hs-identifier hs-var">isEmptySubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865634"><span class="hs-identifier hs-var">subst'</span></a></span><span>
</span><span id="line-405"></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865630"><span class="hs-identifier hs-var">rhss</span></a></span><span>
</span><span id="line-406"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-407"></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865634"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865630"><span class="hs-identifier hs-var">rhss</span></a></span><span>
</span><span id="line-408"></span><span>
</span><span id="line-409"></span><span id="substBind"><span class="annot"><span class="annottext">substBind :: HasDebugCallStack =&gt; Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
</span><a href="GHC.Core.Subst.html#substBind"><span class="hs-identifier hs-var hs-var">substBind</span></a></span></span><span> </span><span id="local-6989586621680865625"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865625"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680865624"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865624"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680865623"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865623"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-410"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865622"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; Bind Id
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865621"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865625"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865623"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-411"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-412"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680865622"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865622"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865621"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865621"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865625"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865624"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-413"></span><span>
</span><span id="line-414"></span><span class="annot"><a href="GHC.Core.Subst.html#substBind"><span class="hs-identifier hs-var">substBind</span></a></span><span> </span><span id="local-6989586621680865620"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865620"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680865619"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865619"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-415"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865618"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; Bind Id
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865617"><span class="hs-identifier hs-var">bndrs'</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [CoreExpr] -&gt; [(Id, CoreExpr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865616"><span class="hs-identifier hs-var">rhss'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-416"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-417"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621680865615"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865615"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865614"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865614"><span class="hs-identifier hs-var">rhss</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; ([Id], [CoreExpr])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680865619"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-418"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621680865618"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865618"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865617"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865617"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substRecBndrs"><span class="hs-identifier hs-var">substRecBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865620"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865615"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-419"></span><span>       </span><span id="local-6989586621680865616"><span class="annot"><span class="annottext">rhss' :: [CoreExpr]
</span><a href="#local-6989586621680865616"><span class="hs-identifier hs-var hs-var">rhss'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865618"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865614"><span class="hs-identifier hs-var">rhss</span></a></span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="hs-comment">-- | De-shadowing the program is sometimes a useful pre-pass. It can be done simply</span><span>
</span><span id="line-422"></span><span class="hs-comment">-- by running over the bindings with an empty substitution, because substitution</span><span>
</span><span id="line-423"></span><span class="hs-comment">-- returns a result that has no-shadowing guaranteed.</span><span>
</span><span id="line-424"></span><span class="hs-comment">--</span><span>
</span><span id="line-425"></span><span class="hs-comment">-- (Actually, within a single /type/ there might still be shadowing, because</span><span>
</span><span id="line-426"></span><span class="hs-comment">-- 'substTy' is a no-op for the empty substitution, but that's probably OK.)</span><span>
</span><span id="line-427"></span><span class="hs-comment">--</span><span>
</span><span id="line-428"></span><span class="hs-comment">-- [Aug 09] This function is not used in GHC at the moment, but seems so</span><span>
</span><span id="line-429"></span><span class="hs-comment">--          short and simple that I'm going to leave it here</span><span>
</span><span id="line-430"></span><span class="annot"><a href="GHC.Core.Subst.html#deShadowBinds"><span class="hs-identifier hs-type">deShadowBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span>
</span><span id="line-431"></span><span id="deShadowBinds"><span class="annot"><span class="annottext">deShadowBinds :: CoreProgram -&gt; CoreProgram
</span><a href="GHC.Core.Subst.html#deShadowBinds"><span class="hs-identifier hs-var hs-var">deShadowBinds</span></a></span></span><span> </span><span id="local-6989586621680865612"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680865612"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Subst, CoreProgram) -&gt; CoreProgram
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Subst -&gt; Bind Id -&gt; (Subst, Bind Id))
-&gt; Subst -&gt; CoreProgram -&gt; (Subst, CoreProgram)
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
</span><a href="GHC.Core.Subst.html#substBind"><span class="hs-identifier hs-var">substBind</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="GHC.Core.Subst.html#emptySubst"><span class="hs-identifier hs-var">emptySubst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680865612"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-432"></span><span>
</span><span id="line-433"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
        Substituting binders
*                                                                      *
************************************************************************

Remember that substBndr and friends are used when doing expression
substitution only.  Their only business is substitution, so they
preserve all IdInfo (suitably substituted).  For example, we *want* to
preserve occ info in rules.
-}</span><span>
</span><span id="line-445"></span><span>
</span><span id="line-446"></span><span class="hs-comment">-- | Substitutes a 'Var' for another one according to the 'Subst' given, returning</span><span>
</span><span id="line-447"></span><span class="hs-comment">-- the result and an updated 'Subst' that should be used by subsequent substitutions.</span><span>
</span><span id="line-448"></span><span class="hs-comment">-- 'IdInfo' is preserved by this process, although it is substituted into appropriately.</span><span>
</span><span id="line-449"></span><span class="annot"><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-type">substBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-450"></span><span id="substBndr"><span class="annot"><span class="annottext">substBndr :: Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var hs-var">substBndr</span></a></span></span><span> </span><span id="local-6989586621680865610"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865610"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865609"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865609"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-451"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865609"><span class="hs-identifier hs-var">bndr</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substTyVarBndr"><span class="hs-identifier hs-var">substTyVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865610"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865609"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-452"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865609"><span class="hs-identifier hs-var">bndr</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substCoVarBndr"><span class="hs-identifier hs-var">substCoVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865610"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865609"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-453"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Subst -&gt; Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substIdBndr"><span class="hs-identifier hs-var">substIdBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;var-bndr&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865610"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865610"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865609"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-454"></span><span>
</span><span id="line-455"></span><span class="hs-comment">-- | Applies 'substBndr' to a number of 'Var's, accumulating a new 'Subst' left-to-right</span><span>
</span><span id="line-456"></span><span class="annot"><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-type">substBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-457"></span><span id="substBndrs"><span class="annot"><span class="annottext">substBndrs :: Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-var hs-var">substBndrs</span></a></span></span><span> </span><span id="local-6989586621680865607"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865607"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865606"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865606"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Subst -&gt; Id -&gt; (Subst, Id)) -&gt; Subst -&gt; [Id] -&gt; (Subst, [Id])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865607"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865606"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-458"></span><span>
</span><span id="line-459"></span><span class="hs-comment">-- | Substitute in a mutually recursive group of 'Id's</span><span>
</span><span id="line-460"></span><span class="annot"><a href="GHC.Core.Subst.html#substRecBndrs"><span class="hs-identifier hs-type">substRecBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-461"></span><span id="substRecBndrs"><span class="annot"><span class="annottext">substRecBndrs :: Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substRecBndrs"><span class="hs-identifier hs-var hs-var">substRecBndrs</span></a></span></span><span> </span><span id="local-6989586621680865605"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865605"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865604"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865604"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-462"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865603"><span class="hs-identifier hs-var">new_subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865602"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-463"></span><span>  </span><span class="hs-keyword">where</span><span>         </span><span class="hs-comment">-- Here's the reason we need to pass rec_subst to subst_id</span><span>
</span><span id="line-464"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680865603"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865603"><span class="hs-identifier hs-var">new_subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865602"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865602"><span class="hs-identifier hs-var">new_bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Subst -&gt; Id -&gt; (Subst, Id)) -&gt; Subst -&gt; [Id] -&gt; (Subst, [Id])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; Subst -&gt; Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substIdBndr"><span class="hs-identifier hs-var">substIdBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rec-bndr&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865603"><span class="hs-identifier hs-var">new_subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865605"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865604"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-465"></span><span>
</span><span id="line-466"></span><span class="annot"><a href="GHC.Core.Subst.html#substIdBndr"><span class="hs-identifier hs-type">substIdBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-467"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>            </span><span class="hs-comment">-- ^ Substitution to use for the IdInfo</span><span>
</span><span id="line-468"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>      </span><span class="hs-comment">-- ^ Substitution and Id to transform</span><span>
</span><span id="line-469"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">)</span><span>      </span><span class="hs-comment">-- ^ Transformed pair</span><span>
</span><span id="line-470"></span><span>                                </span><span class="hs-comment">-- NB: unfolding may be zapped</span><span>
</span><span id="line-471"></span><span>
</span><span id="line-472"></span><span id="substIdBndr"><span class="annot"><span class="annottext">substIdBndr :: SDoc -&gt; Subst -&gt; Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substIdBndr"><span class="hs-identifier hs-var hs-var">substIdBndr</span></a></span></span><span> </span><span id="local-6989586621680865600"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621680865600"><span class="hs-identifier hs-var">_doc</span></a></span></span><span> </span><span id="local-6989586621680865599"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865599"><span class="hs-identifier hs-var">rec_subst</span></a></span></span><span> </span><span id="local-6989586621680865598"><span class="annot"><span class="annottext">subst :: Subst
</span><a href="#local-6989586621680865598"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865597"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865597"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865596"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865596"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680865595"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865595"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865594"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865594"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865593"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865593"><span class="hs-identifier hs-var">old_id</span></a></span></span><span>
</span><span id="line-473"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;substIdBndr&quot; (doc $$ ppr old_id $$ ppr in_scope) $</span><span>
</span><span id="line-474"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865597"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865592"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865591"><span class="hs-identifier hs-var">new_env</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865595"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865594"><span class="hs-identifier hs-var">cvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865592"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-475"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-476"></span><span>    </span><span id="local-6989586621680865590"><span class="annot"><span class="annottext">id1 :: Id
</span><a href="#local-6989586621680865590"><span class="hs-identifier hs-var hs-var">id1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; Id
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865597"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865593"><span class="hs-identifier hs-var">old_id</span></a></span><span>      </span><span class="hs-comment">-- id1 is cloned if necessary</span><span>
</span><span id="line-477"></span><span>    </span><span id="local-6989586621680865588"><span class="annot"><span class="annottext">id2 :: Id
</span><a href="#local-6989586621680865588"><span class="hs-identifier hs-var hs-var">id2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680865587"><span class="hs-identifier hs-var">no_type_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865590"><span class="hs-identifier hs-var">id1</span></a></span><span>
</span><span id="line-478"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Id -&gt; Id
</span><a href="GHC.Types.Var.html#updateIdTypeAndMult"><span class="hs-identifier hs-var">updateIdTypeAndMult</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865598"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865590"><span class="hs-identifier hs-var">id1</span></a></span><span>
</span><span id="line-479"></span><span>
</span><span id="line-480"></span><span>    </span><span id="local-6989586621680865585"><span class="annot"><span class="annottext">old_ty :: Type
</span><a href="#local-6989586621680865585"><span class="hs-identifier hs-var hs-var">old_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865593"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-481"></span><span>    </span><span id="local-6989586621680865583"><span class="annot"><span class="annottext">old_w :: Type
</span><a href="#local-6989586621680865583"><span class="hs-identifier hs-var hs-var">old_w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idMult"><span class="hs-identifier hs-var">idMult</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865593"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-482"></span><span>    </span><span id="local-6989586621680865587"><span class="annot"><span class="annottext">no_type_change :: Bool
</span><a href="#local-6989586621680865587"><span class="hs-identifier hs-var hs-var">no_type_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865595"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865594"><span class="hs-identifier hs-var">cvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-483"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865585"><span class="hs-identifier hs-var">old_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865583"><span class="hs-identifier hs-var">old_w</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-484"></span><span>
</span><span id="line-485"></span><span>        </span><span class="hs-comment">-- new_id has the right IdInfo</span><span>
</span><span id="line-486"></span><span>        </span><span class="hs-comment">-- The lazy-set is because we're in a loop here, with</span><span>
</span><span id="line-487"></span><span>        </span><span class="hs-comment">-- rec_subst, when dealing with a mutually-recursive group</span><span>
</span><span id="line-488"></span><span>    </span><span id="local-6989586621680865592"><span class="annot"><span class="annottext">new_id :: Id
</span><a href="#local-6989586621680865592"><span class="hs-identifier hs-var hs-var">new_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe IdInfo -&gt; Id -&gt; Id
</span><a href="GHC.Types.Id.html#maybeModifyIdInfo"><span class="hs-identifier hs-var">maybeModifyIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe IdInfo
</span><a href="#local-6989586621680865578"><span class="hs-identifier hs-var">mb_new_info</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865588"><span class="hs-identifier hs-var">id2</span></a></span><span>
</span><span id="line-489"></span><span>    </span><span id="local-6989586621680865578"><span class="annot"><span class="annottext">mb_new_info :: Maybe IdInfo
</span><a href="#local-6989586621680865578"><span class="hs-identifier hs-var hs-var">mb_new_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; IdInfo -&gt; Maybe IdInfo
</span><a href="GHC.Core.Subst.html#substIdInfo"><span class="hs-identifier hs-var">substIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865599"><span class="hs-identifier hs-var">rec_subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865588"><span class="hs-identifier hs-var">id2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Id -&gt; IdInfo
Id -&gt; IdInfo
</span><a href="GHC.Types.Var.html#idInfo"><span class="hs-identifier hs-var">idInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865588"><span class="hs-identifier hs-var">id2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-490"></span><span>        </span><span class="hs-comment">-- NB: unfolding info may be zapped</span><span>
</span><span id="line-491"></span><span>
</span><span id="line-492"></span><span>        </span><span class="hs-comment">-- Extend the substitution if the unique has changed</span><span>
</span><span id="line-493"></span><span>        </span><span class="hs-comment">-- See the notes with substTyVarBndr for the delVarEnv</span><span>
</span><span id="line-494"></span><span>    </span><span id="local-6989586621680865591"><span class="annot"><span class="annottext">new_env :: IdSubstEnv
</span><a href="#local-6989586621680865591"><span class="hs-identifier hs-var hs-var">new_env</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680865575"><span class="hs-identifier hs-var">no_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdSubstEnv -&gt; Id -&gt; IdSubstEnv
forall a. VarEnv a -&gt; Id -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865596"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865593"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-495"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdSubstEnv -&gt; Id -&gt; CoreExpr -&gt; IdSubstEnv
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865596"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865593"><span class="hs-identifier hs-var">old_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865592"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-496"></span><span>
</span><span id="line-497"></span><span>    </span><span id="local-6989586621680865575"><span class="annot"><span class="annottext">no_change :: Bool
</span><a href="#local-6989586621680865575"><span class="hs-identifier hs-var hs-var">no_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865590"><span class="hs-identifier hs-var">id1</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865593"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-498"></span><span>        </span><span class="hs-comment">-- See Note [Extending the Subst]</span><span>
</span><span id="line-499"></span><span>        </span><span class="hs-comment">-- it's /not/ necessary to check mb_new_info and no_type_change</span><span>
</span><span id="line-500"></span><span>
</span><span id="line-501"></span><span class="hs-comment">{-
Now a variant that unconditionally allocates a new unique.
It also unconditionally zaps the OccInfo.
-}</span><span>
</span><span id="line-505"></span><span>
</span><span id="line-506"></span><span class="hs-comment">-- | Very similar to 'substBndr', but it always allocates a new 'Unique' for</span><span>
</span><span id="line-507"></span><span class="hs-comment">-- each variable in its output.  It substitutes the IdInfo though.</span><span>
</span><span id="line-508"></span><span class="annot"><a href="GHC.Core.Subst.html#cloneIdBndr"><span class="hs-identifier hs-type">cloneIdBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSupply"><span class="hs-identifier hs-type">UniqSupply</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-509"></span><span id="cloneIdBndr"><span class="annot"><span class="annottext">cloneIdBndr :: Subst -&gt; UniqSupply -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#cloneIdBndr"><span class="hs-identifier hs-var hs-var">cloneIdBndr</span></a></span></span><span> </span><span id="local-6989586621680865572"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865572"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865571"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680865571"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span id="local-6989586621680865570"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865570"><span class="hs-identifier hs-var">old_id</span></a></span></span><span>
</span><span id="line-510"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Subst -&gt; (Id, Unique) -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#clone_id"><span class="hs-identifier hs-var">clone_id</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865572"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865572"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865570"><span class="hs-identifier hs-var">old_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; Unique
</span><a href="GHC.Types.Unique.Supply.html#uniqFromSupply"><span class="hs-identifier hs-var">uniqFromSupply</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680865571"><span class="hs-identifier hs-var">us</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-511"></span><span>
</span><span id="line-512"></span><span class="hs-comment">-- | Applies 'cloneIdBndr' to a number of 'Id's, accumulating a final</span><span>
</span><span id="line-513"></span><span class="hs-comment">-- substitution from left to right</span><span>
</span><span id="line-514"></span><span class="annot"><a href="GHC.Core.Subst.html#cloneIdBndrs"><span class="hs-identifier hs-type">cloneIdBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSupply"><span class="hs-identifier hs-type">UniqSupply</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-515"></span><span id="cloneIdBndrs"><span class="annot"><span class="annottext">cloneIdBndrs :: Subst -&gt; UniqSupply -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#cloneIdBndrs"><span class="hs-identifier hs-var hs-var">cloneIdBndrs</span></a></span></span><span> </span><span id="local-6989586621680865567"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865567"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865566"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680865566"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span id="local-6989586621680865565"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865565"><span class="hs-identifier hs-var">ids</span></a></span></span><span>
</span><span id="line-516"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Subst -&gt; (Id, Unique) -&gt; (Subst, Id))
-&gt; Subst -&gt; [(Id, Unique)] -&gt; (Subst, [Id])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Subst -&gt; (Id, Unique) -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#clone_id"><span class="hs-identifier hs-var">clone_id</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865567"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865567"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865565"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Unique] -&gt; [(Id, Unique)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; [Unique]
</span><a href="GHC.Types.Unique.Supply.html#uniqsFromSupply"><span class="hs-identifier hs-var">uniqsFromSupply</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680865566"><span class="hs-identifier hs-var">us</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-517"></span><span>
</span><span id="line-518"></span><span class="annot"><a href="GHC.Core.Subst.html#cloneBndrs"><span class="hs-identifier hs-type">cloneBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSupply"><span class="hs-identifier hs-type">UniqSupply</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-519"></span><span class="hs-comment">-- Works for all kinds of variables (typically case binders)</span><span>
</span><span id="line-520"></span><span class="hs-comment">-- not just Ids</span><span>
</span><span id="line-521"></span><span id="cloneBndrs"><span class="annot"><span class="annottext">cloneBndrs :: Subst -&gt; UniqSupply -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#cloneBndrs"><span class="hs-identifier hs-var hs-var">cloneBndrs</span></a></span></span><span> </span><span id="local-6989586621680865563"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865563"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865562"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680865562"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span id="local-6989586621680865561"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865561"><span class="hs-identifier hs-var">vs</span></a></span></span><span>
</span><span id="line-522"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Subst -&gt; (Id, Unique) -&gt; (Subst, Id))
-&gt; Subst -&gt; [(Id, Unique)] -&gt; (Subst, [Id])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680865560"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865560"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680865559"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865559"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865558"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865558"><span class="hs-identifier hs-var">u</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Unique -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#cloneBndr"><span class="hs-identifier hs-var">cloneBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865560"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865558"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865559"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865563"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865561"><span class="hs-identifier hs-var">vs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Unique] -&gt; [(Id, Unique)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; [Unique]
</span><a href="GHC.Types.Unique.Supply.html#uniqsFromSupply"><span class="hs-identifier hs-var">uniqsFromSupply</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680865562"><span class="hs-identifier hs-var">us</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-523"></span><span>
</span><span id="line-524"></span><span class="annot"><a href="GHC.Core.Subst.html#cloneBndr"><span class="hs-identifier hs-type">cloneBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Unique"><span class="hs-identifier hs-type">Unique</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-525"></span><span id="cloneBndr"><span class="annot"><span class="annottext">cloneBndr :: Subst -&gt; Unique -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#cloneBndr"><span class="hs-identifier hs-var hs-var">cloneBndr</span></a></span></span><span> </span><span id="local-6989586621680865557"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865557"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865556"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865556"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span id="local-6989586621680865555"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865555"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-526"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865555"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Unique -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#cloneTyVarBndr"><span class="hs-identifier hs-var">cloneTyVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865557"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865555"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865556"><span class="hs-identifier hs-var">uniq</span></a></span><span>
</span><span id="line-527"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Subst -&gt; (Id, Unique) -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#clone_id"><span class="hs-identifier hs-var">clone_id</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865557"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865557"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865555"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865556"><span class="hs-identifier hs-var">uniq</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Works for coercion variables too</span><span>
</span><span id="line-528"></span><span>
</span><span id="line-529"></span><span class="hs-comment">-- | Clone a mutually recursive group of 'Id's</span><span>
</span><span id="line-530"></span><span class="annot"><a href="GHC.Core.Subst.html#cloneRecIdBndrs"><span class="hs-identifier hs-type">cloneRecIdBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#UniqSupply"><span class="hs-identifier hs-type">UniqSupply</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-531"></span><span id="cloneRecIdBndrs"><span class="annot"><span class="annottext">cloneRecIdBndrs :: Subst -&gt; UniqSupply -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#cloneRecIdBndrs"><span class="hs-identifier hs-var hs-var">cloneRecIdBndrs</span></a></span></span><span> </span><span id="local-6989586621680865553"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865553"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865552"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680865552"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span id="local-6989586621680865551"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865551"><span class="hs-identifier hs-var">ids</span></a></span></span><span>
</span><span id="line-532"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865550"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865549"><span class="hs-identifier hs-var">ids'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-533"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-534"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680865550"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865550"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865549"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865549"><span class="hs-identifier hs-var">ids'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Subst -&gt; (Id, Unique) -&gt; (Subst, Id))
-&gt; Subst -&gt; [(Id, Unique)] -&gt; (Subst, [Id])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Subst -&gt; (Id, Unique) -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#clone_id"><span class="hs-identifier hs-var">clone_id</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865550"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865553"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-535"></span><span>                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865551"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Unique] -&gt; [(Id, Unique)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; [Unique]
</span><a href="GHC.Types.Unique.Supply.html#uniqsFromSupply"><span class="hs-identifier hs-var">uniqsFromSupply</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621680865552"><span class="hs-identifier hs-var">us</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-536"></span><span>
</span><span id="line-537"></span><span class="hs-comment">-- Just like substIdBndr, except that it always makes a new unique</span><span>
</span><span id="line-538"></span><span class="hs-comment">-- It is given the unique to use</span><span>
</span><span id="line-539"></span><span class="annot"><a href="GHC.Core.Subst.html#clone_id"><span class="hs-identifier hs-type">clone_id</span></a></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>                    </span><span class="hs-comment">-- Substitution for the IdInfo</span><span>
</span><span id="line-540"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Unique"><span class="hs-identifier hs-type">Unique</span></a></span><span class="hs-special">)</span><span>    </span><span class="hs-comment">-- Substitution and Id to transform</span><span>
</span><span id="line-541"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">)</span><span>              </span><span class="hs-comment">-- Transformed pair</span><span>
</span><span id="line-542"></span><span>
</span><span id="line-543"></span><span id="clone_id"><span class="annot"><span class="annottext">clone_id :: Subst -&gt; Subst -&gt; (Id, Unique) -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#clone_id"><span class="hs-identifier hs-var hs-var">clone_id</span></a></span></span><span> </span><span id="local-6989586621680865547"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865547"><span class="hs-identifier hs-var">rec_subst</span></a></span></span><span> </span><span id="local-6989586621680865546"><span class="annot"><span class="annottext">subst :: Subst
</span><a href="#local-6989586621680865546"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865545"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865545"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865544"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865544"><span class="hs-identifier hs-var">idvs</span></a></span></span><span> </span><span id="local-6989586621680865543"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865543"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680865542"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865542"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680865541"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865541"><span class="hs-identifier hs-var">old_id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865540"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865540"><span class="hs-identifier hs-var">uniq</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-544"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865545"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865539"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865538"><span class="hs-identifier hs-var">new_idvs</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865543"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865537"><span class="hs-identifier hs-var">new_cvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865539"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-545"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-546"></span><span>    </span><span id="local-6989586621680865536"><span class="annot"><span class="annottext">id1 :: Id
</span><a href="#local-6989586621680865536"><span class="hs-identifier hs-var hs-var">id1</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unique -&gt; Id
</span><a href="GHC.Types.Var.html#setVarUnique"><span class="hs-identifier hs-var">setVarUnique</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865541"><span class="hs-identifier hs-var">old_id</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865540"><span class="hs-identifier hs-var">uniq</span></a></span><span>
</span><span id="line-547"></span><span>    </span><span id="local-6989586621680865534"><span class="annot"><span class="annottext">id2 :: Id
</span><a href="#local-6989586621680865534"><span class="hs-identifier hs-var hs-var">id2</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Id
</span><a href="GHC.Core.Subst.html#substIdType"><span class="hs-identifier hs-var">substIdType</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865546"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865536"><span class="hs-identifier hs-var">id1</span></a></span><span>
</span><span id="line-548"></span><span>    </span><span id="local-6989586621680865539"><span class="annot"><span class="annottext">new_id :: Id
</span><a href="#local-6989586621680865539"><span class="hs-identifier hs-var hs-var">new_id</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe IdInfo -&gt; Id -&gt; Id
</span><a href="GHC.Types.Id.html#maybeModifyIdInfo"><span class="hs-identifier hs-var">maybeModifyIdInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; IdInfo -&gt; Maybe IdInfo
</span><a href="GHC.Core.Subst.html#substIdInfo"><span class="hs-identifier hs-var">substIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865547"><span class="hs-identifier hs-var">rec_subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865534"><span class="hs-identifier hs-var">id2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Id -&gt; IdInfo
Id -&gt; IdInfo
</span><a href="GHC.Types.Var.html#idInfo"><span class="hs-identifier hs-var">idInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865541"><span class="hs-identifier hs-var">old_id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865534"><span class="hs-identifier hs-var">id2</span></a></span><span>
</span><span id="line-549"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680865538"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865538"><span class="hs-identifier hs-var">new_idvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865537"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865537"><span class="hs-identifier hs-var">new_cvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865541"><span class="hs-identifier hs-var">old_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865544"><span class="hs-identifier hs-var">idvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Id -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865542"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865541"><span class="hs-identifier hs-var">old_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier hs-var">mkCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865539"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-550"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSubstEnv -&gt; Id -&gt; CoreExpr -&gt; IdSubstEnv
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865544"><span class="hs-identifier hs-var">idvs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865541"><span class="hs-identifier hs-var">old_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865539"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865542"><span class="hs-identifier hs-var">cvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-551"></span><span>
</span><span id="line-552"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Types and Coercions
*                                                                      *
************************************************************************

For types and coercions we just call the corresponding functions in
Type and Coercion, but we have to repackage the substitution, from a
Subst to a TCvSubst.
-}</span><span>
</span><span id="line-563"></span><span>
</span><span id="line-564"></span><span class="annot"><a href="GHC.Core.Subst.html#substTyVarBndr"><span class="hs-identifier hs-type">substTyVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-565"></span><span id="substTyVarBndr"><span class="annot"><span class="annottext">substTyVarBndr :: Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substTyVarBndr"><span class="hs-identifier hs-var hs-var">substTyVarBndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865532"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865532"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865531"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865531"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span id="local-6989586621680865530"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865530"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span id="local-6989586621680865529"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865529"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865528"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865528"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-566"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Id -&gt; (TCvSubst, Id)
TCvSubst -&gt; Id -&gt; (TCvSubst, Id)
</span><a href="GHC.Core.TyCo.Subst.html#substTyVarBndr"><span class="hs-identifier hs-var">Type.substTyVarBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865532"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865530"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865529"><span class="hs-identifier hs-var">cv_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865528"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-567"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680865526"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865526"><span class="hs-identifier hs-var">in_scope'</span></a></span></span><span> </span><span id="local-6989586621680865525"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865525"><span class="hs-identifier hs-var">tv_env'</span></a></span></span><span> </span><span id="local-6989586621680865524"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865524"><span class="hs-identifier hs-var">cv_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865523"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865523"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-568"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865526"><span class="hs-identifier hs-var">in_scope'</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865531"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865525"><span class="hs-identifier hs-var">tv_env'</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865524"><span class="hs-identifier hs-var">cv_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865523"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-569"></span><span>
</span><span id="line-570"></span><span class="annot"><a href="GHC.Core.Subst.html#cloneTyVarBndr"><span class="hs-identifier hs-type">cloneTyVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Unique"><span class="hs-identifier hs-type">Unique</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-571"></span><span id="cloneTyVarBndr"><span class="annot"><span class="annottext">cloneTyVarBndr :: Subst -&gt; Id -&gt; Unique -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#cloneTyVarBndr"><span class="hs-identifier hs-var hs-var">cloneTyVarBndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865522"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865522"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865521"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865521"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span id="local-6989586621680865520"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865520"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span id="local-6989586621680865519"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865519"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865518"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865518"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680865517"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865517"><span class="hs-identifier hs-var">uniq</span></a></span></span><span>
</span><span id="line-572"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Id -&gt; Unique -&gt; (TCvSubst, Id)
</span><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndr"><span class="hs-identifier hs-var">Type.cloneTyVarBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865522"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865520"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865519"><span class="hs-identifier hs-var">cv_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865518"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621680865517"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-573"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680865516"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865516"><span class="hs-identifier hs-var">in_scope'</span></a></span></span><span> </span><span id="local-6989586621680865515"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865515"><span class="hs-identifier hs-var">tv_env'</span></a></span></span><span> </span><span id="local-6989586621680865514"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865514"><span class="hs-identifier hs-var">cv_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865513"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865513"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-574"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865516"><span class="hs-identifier hs-var">in_scope'</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865521"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865515"><span class="hs-identifier hs-var">tv_env'</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865514"><span class="hs-identifier hs-var">cv_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865513"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-575"></span><span>
</span><span id="line-576"></span><span class="annot"><a href="GHC.Core.Subst.html#substCoVarBndr"><span class="hs-identifier hs-type">substCoVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-577"></span><span id="substCoVarBndr"><span class="annot"><span class="annottext">substCoVarBndr :: Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substCoVarBndr"><span class="hs-identifier hs-var hs-var">substCoVarBndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865512"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865512"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680865511"><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865511"><span class="hs-identifier hs-var">id_env</span></a></span></span><span> </span><span id="local-6989586621680865510"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865510"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span id="local-6989586621680865509"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865509"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865508"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865508"><span class="hs-identifier hs-var">cv</span></a></span></span><span>
</span><span id="line-578"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Id -&gt; (TCvSubst, Id)
TCvSubst -&gt; Id -&gt; (TCvSubst, Id)
</span><a href="GHC.Core.TyCo.Subst.html#substCoVarBndr"><span class="hs-identifier hs-var">Coercion.substCoVarBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865512"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865510"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865509"><span class="hs-identifier hs-var">cv_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865508"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-579"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680865507"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865507"><span class="hs-identifier hs-var">in_scope'</span></a></span></span><span> </span><span id="local-6989586621680865506"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865506"><span class="hs-identifier hs-var">tv_env'</span></a></span></span><span> </span><span id="local-6989586621680865505"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865505"><span class="hs-identifier hs-var">cv_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865504"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865504"><span class="hs-identifier hs-var">cv'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-580"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; IdSubstEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; Subst
</span><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-var">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865507"><span class="hs-identifier hs-var">in_scope'</span></a></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><a href="#local-6989586621680865511"><span class="hs-identifier hs-var">id_env</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865506"><span class="hs-identifier hs-var">tv_env'</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865505"><span class="hs-identifier hs-var">cv_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865504"><span class="hs-identifier hs-var">cv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-581"></span><span>
</span><span id="line-582"></span><span class="hs-comment">-- | See 'Type.substTy'</span><span>
</span><span id="line-583"></span><span class="annot"><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-type">substTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-584"></span><span id="substTy"><span class="annot"><span class="annottext">substTy :: Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var hs-var">substTy</span></a></span></span><span> </span><span id="local-6989586621680865503"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865503"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865502"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865502"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">Type.substTyUnchecked</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; TCvSubst
</span><a href="GHC.Core.Subst.html#getTCvSubst"><span class="hs-identifier hs-var">getTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865503"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865502"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-585"></span><span>
</span><span id="line-586"></span><span class="annot"><a href="GHC.Core.Subst.html#getTCvSubst"><span class="hs-identifier hs-type">getTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-587"></span><span id="getTCvSubst"><span class="annot"><span class="annottext">getTCvSubst :: Subst -&gt; TCvSubst
</span><a href="GHC.Core.Subst.html#getTCvSubst"><span class="hs-identifier hs-var hs-var">getTCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span id="local-6989586621680865500"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865500"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680865499"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865499"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680865498"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865498"><span class="hs-identifier hs-var">cenv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680865500"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865499"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865498"><span class="hs-identifier hs-var">cenv</span></a></span><span>
</span><span id="line-588"></span><span>
</span><span id="line-589"></span><span class="hs-comment">-- | See 'Coercion.substCo'</span><span>
</span><span id="line-590"></span><span class="annot"><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-type">substCo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-591"></span><span id="substCo"><span class="annot"><span class="annottext">substCo :: HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var hs-var">substCo</span></a></span></span><span> </span><span id="local-6989586621680865494"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865494"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865493"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865493"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">Coercion.substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; TCvSubst
</span><a href="GHC.Core.Subst.html#getTCvSubst"><span class="hs-identifier hs-var">getTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865494"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680865493"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-592"></span><span>
</span><span id="line-593"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\section{IdInfo substitution}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-600"></span><span>
</span><span id="line-601"></span><span class="annot"><a href="GHC.Core.Subst.html#substIdType"><span class="hs-identifier hs-type">substIdType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-602"></span><span id="substIdType"><span class="annot"><span class="annottext">substIdType :: Subst -&gt; Id -&gt; Id
</span><a href="GHC.Core.Subst.html#substIdType"><span class="hs-identifier hs-var hs-var">substIdType</span></a></span></span><span> </span><span id="local-6989586621680865492"><span class="annot"><span class="annottext">subst :: Subst
</span><a href="#local-6989586621680865492"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">IdSubstEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680865491"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865491"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span id="local-6989586621680865490"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865490"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680865489"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865489"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-603"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680865491"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680865490"><span class="hs-identifier hs-var">cv_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-604"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865488"><span class="hs-identifier hs-var">old_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680865487"><span class="hs-identifier hs-var">old_w</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865489"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-605"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span>
</span><span id="line-606"></span><span>      </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Id -&gt; Id
</span><a href="GHC.Types.Var.html#updateIdTypeAndMult"><span class="hs-identifier hs-var">updateIdTypeAndMult</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865492"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865489"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-607"></span><span>        </span><span class="hs-comment">-- The tyCoVarsOfType is cheaper than it looks</span><span>
</span><span id="line-608"></span><span>        </span><span class="hs-comment">-- because we cache the free tyvars of the type</span><span>
</span><span id="line-609"></span><span>        </span><span class="hs-comment">-- in a Note in the id's type itself</span><span>
</span><span id="line-610"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-611"></span><span>    </span><span id="local-6989586621680865488"><span class="annot"><span class="annottext">old_ty :: Type
</span><a href="#local-6989586621680865488"><span class="hs-identifier hs-var hs-var">old_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865489"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-612"></span><span>    </span><span id="local-6989586621680865487"><span class="annot"><span class="annottext">old_w :: Type
</span><a href="#local-6989586621680865487"><span class="hs-identifier hs-var hs-var">old_w</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Var.html#varMult"><span class="hs-identifier hs-var hs-var">varMult</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865489"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-613"></span><span>
</span><span id="line-614"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-615"></span><span class="hs-comment">-- | Substitute into some 'IdInfo' with regard to the supplied new 'Id'.</span><span>
</span><span id="line-616"></span><span class="annot"><a href="GHC.Core.Subst.html#substIdInfo"><span class="hs-identifier hs-type">substIdInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#IdInfo"><span class="hs-identifier hs-type">IdInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#IdInfo"><span class="hs-identifier hs-type">IdInfo</span></a></span><span>
</span><span id="line-617"></span><span id="substIdInfo"><span class="annot"><span class="annottext">substIdInfo :: Subst -&gt; Id -&gt; IdInfo -&gt; Maybe IdInfo
</span><a href="GHC.Core.Subst.html#substIdInfo"><span class="hs-identifier hs-var hs-var">substIdInfo</span></a></span></span><span> </span><span id="local-6989586621680865485"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865485"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865484"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865484"><span class="hs-identifier hs-var">new_id</span></a></span></span><span> </span><span id="local-6989586621680865483"><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621680865483"><span class="hs-identifier hs-var">info</span></a></span></span><span>
</span><span id="line-618"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680865482"><span class="hs-identifier hs-var">nothing_to_do</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe IdInfo
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-619"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; Maybe IdInfo
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621680865483"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; RuleInfo -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setRuleInfo"><span class="hs-operator hs-var">`setRuleInfo`</span></a></span><span>      </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; RuleInfo -&gt; RuleInfo
</span><a href="GHC.Core.Subst.html#substSpec"><span class="hs-identifier hs-var">substSpec</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865485"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865484"><span class="hs-identifier hs-var">new_id</span></a></span><span> </span><span class="annot"><span class="annottext">RuleInfo
</span><a href="#local-6989586621680865480"><span class="hs-identifier hs-var">old_rules</span></a></span><span>
</span><span id="line-620"></span><span>                               </span><span class="annot"><span class="annottext">IdInfo -&gt; Unfolding -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setUnfoldingInfo"><span class="hs-operator hs-var">`setUnfoldingInfo`</span></a></span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Unfolding -&gt; Unfolding
</span><a href="GHC.Core.Subst.html#substUnfolding"><span class="hs-identifier hs-var">substUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865485"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865478"><span class="hs-identifier hs-var">old_unf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-621"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-622"></span><span>    </span><span id="local-6989586621680865480"><span class="annot"><span class="annottext">old_rules :: RuleInfo
</span><a href="#local-6989586621680865480"><span class="hs-identifier hs-var hs-var">old_rules</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; RuleInfo
</span><a href="GHC.Types.Id.Info.html#ruleInfo"><span class="hs-identifier hs-var hs-var">ruleInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621680865483"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-623"></span><span>    </span><span id="local-6989586621680865478"><span class="annot"><span class="annottext">old_unf :: Unfolding
</span><a href="#local-6989586621680865478"><span class="hs-identifier hs-var hs-var">old_unf</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; Unfolding
</span><a href="GHC.Types.Id.Info.html#unfoldingInfo"><span class="hs-identifier hs-var hs-var">unfoldingInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621680865483"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-624"></span><span>    </span><span id="local-6989586621680865482"><span class="annot"><span class="annottext">nothing_to_do :: Bool
</span><a href="#local-6989586621680865482"><span class="hs-identifier hs-var hs-var">nothing_to_do</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RuleInfo -&gt; Bool
</span><a href="GHC.Types.Id.Info.html#isEmptyRuleInfo"><span class="hs-identifier hs-var">isEmptyRuleInfo</span></a></span><span> </span><span class="annot"><span class="annottext">RuleInfo
</span><a href="#local-6989586621680865480"><span class="hs-identifier hs-var">old_rules</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="GHC.Core.html#hasCoreUnfolding"><span class="hs-identifier hs-var">hasCoreUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865478"><span class="hs-identifier hs-var">old_unf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-625"></span><span>
</span><span id="line-626"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-627"></span><span class="hs-comment">-- | Substitutes for the 'Id's within an unfolding</span><span>
</span><span id="line-628"></span><span class="annot"><a href="GHC.Core.Subst.html#substUnfolding"><span class="hs-identifier hs-type">substUnfolding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#substUnfoldingSC"><span class="hs-identifier hs-type">substUnfoldingSC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Unfolding"><span class="hs-identifier hs-type">Unfolding</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Unfolding"><span class="hs-identifier hs-type">Unfolding</span></a></span><span>
</span><span id="line-629"></span><span>        </span><span class="hs-comment">-- Seq'ing on the returned Unfolding is enough to cause</span><span>
</span><span id="line-630"></span><span>        </span><span class="hs-comment">-- all the substitutions to happen completely</span><span>
</span><span id="line-631"></span><span>
</span><span id="line-632"></span><span id="substUnfoldingSC"><span class="annot"><span class="annottext">substUnfoldingSC :: Subst -&gt; Unfolding -&gt; Unfolding
</span><a href="GHC.Core.Subst.html#substUnfoldingSC"><span class="hs-identifier hs-var hs-var">substUnfoldingSC</span></a></span></span><span> </span><span id="local-6989586621680865473"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865473"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865472"><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865472"><span class="hs-identifier hs-var">unf</span></a></span></span><span>       </span><span class="hs-comment">-- Short-cut version</span><span>
</span><span id="line-633"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Bool
</span><a href="GHC.Core.Subst.html#isEmptySubst"><span class="hs-identifier hs-var">isEmptySubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865473"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865472"><span class="hs-identifier hs-var">unf</span></a></span><span>
</span><span id="line-634"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Unfolding -&gt; Unfolding
</span><a href="GHC.Core.Subst.html#substUnfolding"><span class="hs-identifier hs-var">substUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865473"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865472"><span class="hs-identifier hs-var">unf</span></a></span><span>
</span><span id="line-635"></span><span>
</span><span id="line-636"></span><span id="substUnfolding"><span class="annot"><span class="annottext">substUnfolding :: Subst -&gt; Unfolding -&gt; Unfolding
</span><a href="GHC.Core.Subst.html#substUnfolding"><span class="hs-identifier hs-var hs-var">substUnfolding</span></a></span></span><span> </span><span id="local-6989586621680865471"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865471"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865470"><span class="annot"><span class="annottext">df :: Unfolding
</span><a href="#local-6989586621680865470"><span class="hs-identifier hs-var">df</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DFunUnfolding"><span class="hs-identifier hs-type">DFunUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">df_bndrs :: Unfolding -&gt; [Id]
</span><a href="GHC.Core.html#df_bndrs"><span class="hs-identifier hs-var">df_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865467"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865467"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">df_args :: Unfolding -&gt; [CoreExpr]
</span><a href="GHC.Core.html#df_args"><span class="hs-identifier hs-var">df_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865465"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865465"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-637"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865470"><span class="hs-identifier hs-var">df</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">df_bndrs :: [Id]
</span><a href="GHC.Core.html#df_bndrs"><span class="hs-identifier hs-var">df_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865464"><span class="hs-identifier hs-var">bndrs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">df_args :: [CoreExpr]
</span><a href="GHC.Core.html#df_args"><span class="hs-identifier hs-var">df_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865463"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-638"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-639"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680865462"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865462"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680865464"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865464"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865471"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865467"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-640"></span><span>    </span><span id="local-6989586621680865463"><span class="annot"><span class="annottext">args' :: [CoreExpr]
</span><a href="#local-6989586621680865463"><span class="hs-identifier hs-var hs-var">args'</span></a></span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865462"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865465"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-641"></span><span>
</span><span id="line-642"></span><span class="annot"><a href="GHC.Core.Subst.html#substUnfolding"><span class="hs-identifier hs-var">substUnfolding</span></a></span><span> </span><span id="local-6989586621680865460"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865460"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865459"><span class="annot"><span class="annottext">unf :: Unfolding
</span><a href="#local-6989586621680865459"><span class="hs-identifier hs-var">unf</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_tmpl :: Unfolding -&gt; CoreExpr
</span><a href="GHC.Core.html#uf_tmpl"><span class="hs-identifier hs-var">uf_tmpl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865456"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865456"><span class="hs-identifier hs-var">tmpl</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uf_src :: Unfolding -&gt; UnfoldingSource
</span><a href="GHC.Core.html#uf_src"><span class="hs-identifier hs-var">uf_src</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865454"><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680865454"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-643"></span><span>        </span><span class="hs-comment">-- Retain an InlineRule!</span><span>
</span><span id="line-644"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnfoldingSource -&gt; Bool
</span><a href="GHC.Core.html#isStableSource"><span class="hs-identifier hs-var">isStableSource</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621680865454"><span class="hs-identifier hs-var">src</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Zap an unstable unfolding, to save substitution work</span><span>
</span><span id="line-645"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="GHC.Core.html#NoUnfolding"><span class="hs-identifier hs-var">NoUnfolding</span></a></span><span>
</span><span id="line-646"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                 </span><span class="hs-comment">-- But keep a stable one!</span><span>
</span><span id="line-647"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; ()
</span><a href="GHC.Core.Seq.html#seqExpr"><span class="hs-identifier hs-var">seqExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865450"><span class="hs-identifier hs-var">new_tmpl</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; Unfolding -&gt; Unfolding
</span><span class="hs-operator hs-var">`seq`</span></span><span>
</span><span id="line-648"></span><span>    </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865459"><span class="hs-identifier hs-var">unf</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_tmpl :: CoreExpr
</span><a href="GHC.Core.html#uf_tmpl"><span class="hs-identifier hs-var">uf_tmpl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865450"><span class="hs-identifier hs-var">new_tmpl</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-649"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-650"></span><span>    </span><span id="local-6989586621680865450"><span class="annot"><span class="annottext">new_tmpl :: CoreExpr
</span><a href="#local-6989586621680865450"><span class="hs-identifier hs-var hs-var">new_tmpl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865460"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865456"><span class="hs-identifier hs-var">tmpl</span></a></span><span>
</span><span id="line-651"></span><span>
</span><span id="line-652"></span><span class="annot"><a href="GHC.Core.Subst.html#substUnfolding"><span class="hs-identifier hs-var">substUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680865448"><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865448"><span class="hs-identifier hs-var">unf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621680865448"><span class="hs-identifier hs-var">unf</span></a></span><span>      </span><span class="hs-comment">-- NoUnfolding, OtherCon</span><span>
</span><span id="line-653"></span><span>
</span><span id="line-654"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-655"></span><span class="annot"><a href="GHC.Core.Subst.html#substIdOcc"><span class="hs-identifier hs-type">substIdOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-656"></span><span class="hs-comment">-- These Ids should not be substituted to non-Ids</span><span>
</span><span id="line-657"></span><span id="substIdOcc"><span class="annot"><span class="annottext">substIdOcc :: Subst -&gt; Id -&gt; Id
</span><a href="GHC.Core.Subst.html#substIdOcc"><span class="hs-identifier hs-var hs-var">substIdOcc</span></a></span></span><span> </span><span id="local-6989586621680865447"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865447"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865446"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865446"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Id -&gt; CoreExpr
Subst -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-var">lookupIdSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865447"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865446"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-658"></span><span>                        </span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680865445"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865445"><span class="hs-identifier hs-var">v'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865445"><span class="hs-identifier hs-var">v'</span></a></span><span>
</span><span id="line-659"></span><span>                        </span><span id="local-6989586621680865444"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865444"><span class="hs-identifier hs-var">other</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; Id
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;substIdOcc&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865446"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865444"><span class="hs-identifier hs-var">other</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865447"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-660"></span><span>
</span><span id="line-661"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-662"></span><span class="hs-comment">-- | Substitutes for the 'Id's within the 'WorkerInfo' given the new function 'Id'</span><span>
</span><span id="line-663"></span><span class="annot"><a href="GHC.Core.Subst.html#substSpec"><span class="hs-identifier hs-type">substSpec</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#RuleInfo"><span class="hs-identifier hs-type">RuleInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#RuleInfo"><span class="hs-identifier hs-type">RuleInfo</span></a></span><span>
</span><span id="line-664"></span><span id="substSpec"><span class="annot"><span class="annottext">substSpec :: Subst -&gt; Id -&gt; RuleInfo -&gt; RuleInfo
</span><a href="GHC.Core.Subst.html#substSpec"><span class="hs-identifier hs-var hs-var">substSpec</span></a></span></span><span> </span><span id="local-6989586621680865441"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865441"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865440"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865440"><span class="hs-identifier hs-var">new_id</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Id.Info.html#RuleInfo"><span class="hs-identifier hs-type">RuleInfo</span></a></span><span> </span><span id="local-6989586621680865438"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680865438"><span class="hs-identifier hs-var">rules</span></a></span></span><span> </span><span id="local-6989586621680865437"><span class="annot"><span class="annottext">DVarSet
</span><a href="#local-6989586621680865437"><span class="hs-identifier hs-var">rhs_fvs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-665"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RuleInfo -&gt; ()
</span><a href="GHC.Core.Seq.html#seqRuleInfo"><span class="hs-identifier hs-var">seqRuleInfo</span></a></span><span> </span><span class="annot"><span class="annottext">RuleInfo
</span><a href="#local-6989586621680865435"><span class="hs-identifier hs-var">new_spec</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; RuleInfo -&gt; RuleInfo
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">RuleInfo
</span><a href="#local-6989586621680865435"><span class="hs-identifier hs-var">new_spec</span></a></span><span>
</span><span id="line-666"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-667"></span><span>    </span><span id="local-6989586621680865434"><span class="annot"><span class="annottext">subst_ru_fn :: b -&gt; Name
</span><a href="#local-6989586621680865434"><span class="hs-identifier hs-var hs-var">subst_ru_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; b -&gt; Name
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865440"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-668"></span><span>    </span><span id="local-6989586621680865435"><span class="annot"><span class="annottext">new_spec :: RuleInfo
</span><a href="#local-6989586621680865435"><span class="hs-identifier hs-var hs-var">new_spec</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreRule] -&gt; DVarSet -&gt; RuleInfo
</span><a href="GHC.Types.Id.Info.html#RuleInfo"><span class="hs-identifier hs-var">RuleInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CoreRule -&gt; CoreRule) -&gt; [CoreRule] -&gt; [CoreRule]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; (Name -&gt; Name) -&gt; CoreRule -&gt; CoreRule
</span><a href="GHC.Core.Subst.html#substRule"><span class="hs-identifier hs-var">substRule</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865441"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name
forall {b}. b -&gt; Name
</span><a href="#local-6989586621680865434"><span class="hs-identifier hs-var">subst_ru_fn</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680865438"><span class="hs-identifier hs-var">rules</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-669"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; DVarSet -&gt; DVarSet
</span><a href="GHC.Core.Subst.html#substDVarSet"><span class="hs-identifier hs-var">substDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865441"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DVarSet
</span><a href="#local-6989586621680865437"><span class="hs-identifier hs-var">rhs_fvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-670"></span><span>
</span><span id="line-671"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-672"></span><span class="annot"><a href="GHC.Core.Subst.html#substRulesForImportedIds"><span class="hs-identifier hs-type">substRulesForImportedIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-673"></span><span id="substRulesForImportedIds"><span class="annot"><span class="annottext">substRulesForImportedIds :: Subst -&gt; [CoreRule] -&gt; [CoreRule]
</span><a href="GHC.Core.Subst.html#substRulesForImportedIds"><span class="hs-identifier hs-var hs-var">substRulesForImportedIds</span></a></span></span><span> </span><span id="local-6989586621680865430"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865430"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865429"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680865429"><span class="hs-identifier hs-var">rules</span></a></span></span><span>
</span><span id="line-674"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreRule -&gt; CoreRule) -&gt; [CoreRule] -&gt; [CoreRule]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; (Name -&gt; Name) -&gt; CoreRule -&gt; CoreRule
</span><a href="GHC.Core.Subst.html#substRule"><span class="hs-identifier hs-var">substRule</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865430"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name
forall {a} {a}. Outputable a =&gt; a -&gt; a
</span><a href="#local-6989586621680865428"><span class="hs-identifier hs-var">not_needed</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621680865429"><span class="hs-identifier hs-var">rules</span></a></span><span>
</span><span id="line-675"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-676"></span><span>    </span><span id="local-6989586621680865428"><span class="annot"><span class="annottext">not_needed :: a -&gt; a
</span><a href="#local-6989586621680865428"><span class="hs-identifier hs-var hs-var">not_needed</span></a></span></span><span> </span><span id="local-6989586621680865423"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680865423"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; a
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;substRulesForImportedIds&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680865423"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-677"></span><span>
</span><span id="line-678"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-679"></span><span class="annot"><a href="GHC.Core.Subst.html#substRule"><span class="hs-identifier hs-type">substRule</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span>
</span><span id="line-680"></span><span>
</span><span id="line-681"></span><span class="hs-comment">-- The subst_ru_fn argument is applied to substitute the ru_fn field</span><span>
</span><span id="line-682"></span><span class="hs-comment">-- of the rule:</span><span>
</span><span id="line-683"></span><span class="hs-comment">--    - Rules for *imported* Ids never change ru_fn</span><span>
</span><span id="line-684"></span><span class="hs-comment">--    - Rules for *local* Ids are in the IdInfo for that Id,</span><span>
</span><span id="line-685"></span><span class="hs-comment">--      and the ru_fn field is simply replaced by the new name</span><span>
</span><span id="line-686"></span><span class="hs-comment">--      of the Id</span><span>
</span><span id="line-687"></span><span id="substRule"><span class="annot"><span class="annottext">substRule :: Subst -&gt; (Name -&gt; Name) -&gt; CoreRule -&gt; CoreRule
</span><a href="GHC.Core.Subst.html#substRule"><span class="hs-identifier hs-var hs-var">substRule</span></a></span></span><span> </span><span class="annot"><span class="annottext">Subst
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680865422"><span class="annot"><span class="annottext">rule :: CoreRule
</span><a href="#local-6989586621680865422"><span class="hs-identifier hs-var">rule</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#BuiltinRule"><span class="hs-identifier hs-type">BuiltinRule</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680865422"><span class="hs-identifier hs-var">rule</span></a></span><span>
</span><span id="line-688"></span><span class="annot"><a href="GHC.Core.Subst.html#substRule"><span class="hs-identifier hs-var">substRule</span></a></span><span> </span><span id="local-6989586621680865420"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865420"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865419"><span class="annot"><span class="annottext">Name -&gt; Name
</span><a href="#local-6989586621680865419"><span class="hs-identifier hs-var">subst_ru_fn</span></a></span></span><span> </span><span id="local-6989586621680865418"><span class="annot"><span class="annottext">rule :: CoreRule
</span><a href="#local-6989586621680865418"><span class="hs-identifier hs-var">rule</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rule"><span class="hs-identifier hs-type">Rule</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ru_bndrs :: CoreRule -&gt; [Id]
</span><a href="GHC.Core.html#ru_bndrs"><span class="hs-identifier hs-var">ru_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865415"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865415"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_args :: CoreRule -&gt; [CoreExpr]
</span><a href="GHC.Core.html#ru_args"><span class="hs-identifier hs-var">ru_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865413"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865413"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-689"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_fn :: CoreRule -&gt; Name
</span><a href="GHC.Core.html#ru_fn"><span class="hs-identifier hs-var">ru_fn</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865411"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680865411"><span class="hs-identifier hs-var">fn_name</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_rhs :: CoreRule -&gt; CoreExpr
</span><a href="GHC.Core.html#ru_rhs"><span class="hs-identifier hs-var">ru_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865409"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865409"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-690"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_local :: CoreRule -&gt; Bool
</span><a href="GHC.Core.html#ru_local"><span class="hs-identifier hs-var">ru_local</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680865407"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680865407"><span class="hs-identifier hs-var">is_local</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-691"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680865418"><span class="hs-identifier hs-var">rule</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ru_bndrs :: [Id]
</span><a href="GHC.Core.html#ru_bndrs"><span class="hs-identifier hs-var">ru_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865406"><span class="hs-identifier hs-var">bndrs'</span></a></span><span>
</span><span id="line-692"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_fn :: Name
</span><a href="GHC.Core.html#ru_fn"><span class="hs-identifier hs-var">ru_fn</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680865407"><span class="hs-identifier hs-var">is_local</span></a></span><span>
</span><span id="line-693"></span><span>                        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name
</span><a href="#local-6989586621680865419"><span class="hs-identifier hs-var">subst_ru_fn</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680865411"><span class="hs-identifier hs-var">fn_name</span></a></span><span>
</span><span id="line-694"></span><span>                        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680865411"><span class="hs-identifier hs-var">fn_name</span></a></span><span>
</span><span id="line-695"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_args :: [CoreExpr]
</span><a href="GHC.Core.html#ru_args"><span class="hs-identifier hs-var">ru_args</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865405"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680865413"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-696"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_rhs :: CoreExpr
</span><a href="GHC.Core.html#ru_rhs"><span class="hs-identifier hs-var">ru_rhs</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865405"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680865409"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-697"></span><span>           </span><span class="hs-comment">-- Do NOT optimise the RHS (previously we did simplOptExpr here)</span><span>
</span><span id="line-698"></span><span>           </span><span class="hs-comment">-- See Note [Substitute lazily]</span><span>
</span><span id="line-699"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-700"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680865405"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865405"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680865406"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865406"><span class="hs-identifier hs-var">bndrs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865420"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865415"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-701"></span><span>
</span><span id="line-702"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-703"></span><span class="annot"><a href="GHC.Core.Subst.html#substDVarSet"><span class="hs-identifier hs-type">substDVarSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span>
</span><span id="line-704"></span><span id="substDVarSet"><span class="annot"><span class="annottext">substDVarSet :: Subst -&gt; DVarSet -&gt; DVarSet
</span><a href="GHC.Core.Subst.html#substDVarSet"><span class="hs-identifier hs-var hs-var">substDVarSet</span></a></span></span><span> </span><span id="local-6989586621680865404"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865404"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865403"><span class="annot"><span class="annottext">DVarSet
</span><a href="#local-6989586621680865403"><span class="hs-identifier hs-var">fvs</span></a></span></span><span>
</span><span id="line-705"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; DVarSet
</span><a href="GHC.Types.Var.Set.html#mkDVarSet"><span class="hs-identifier hs-var">mkDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; DVarSet) -&gt; [Id] -&gt; DVarSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">([Id], VarSet) -&gt; [Id]
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(([Id], VarSet) -&gt; [Id]) -&gt; ([Id], VarSet) -&gt; [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; ([Id], VarSet) -&gt; ([Id], VarSet))
-&gt; ([Id], VarSet) -&gt; [Id] -&gt; ([Id], VarSet)
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; ([Id], VarSet) -&gt; ([Id], VarSet)
</span><a href="#local-6989586621680865400"><span class="hs-identifier hs-var">subst_fv</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865404"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; ([Id], VarSet)) -&gt; [Id] -&gt; ([Id], VarSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DVarSet -&gt; [Id]
</span><a href="GHC.Types.Var.Set.html#dVarSetElems"><span class="hs-identifier hs-var">dVarSetElems</span></a></span><span> </span><span class="annot"><span class="annottext">DVarSet
</span><a href="#local-6989586621680865403"><span class="hs-identifier hs-var">fvs</span></a></span><span>
</span><span id="line-706"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-707"></span><span>  </span><span id="local-6989586621680865400"><span class="annot"><span class="annottext">subst_fv :: Subst -&gt; Id -&gt; ([Id], VarSet) -&gt; ([Id], VarSet)
</span><a href="#local-6989586621680865400"><span class="hs-identifier hs-var hs-var">subst_fv</span></a></span></span><span> </span><span id="local-6989586621680865396"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865396"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680865395"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865395"><span class="hs-identifier hs-var">fv</span></a></span></span><span> </span><span id="local-6989586621680865394"><span class="annot"><span class="annottext">([Id], VarSet)
</span><a href="#local-6989586621680865394"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-708"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865395"><span class="hs-identifier hs-var">fv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; FV
</span><a href="GHC.Core.FVs.html#expr_fvs"><span class="hs-identifier hs-var">expr_fvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Id -&gt; CoreExpr
Subst -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-var">lookupIdSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865396"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865395"><span class="hs-identifier hs-var">fv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalVar"><span class="hs-identifier hs-var">isLocalVar</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(([Id], VarSet) -&gt; ([Id], VarSet))
-&gt; ([Id], VarSet) -&gt; ([Id], VarSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">([Id], VarSet)
</span><a href="#local-6989586621680865394"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-709"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; FV
</span><a href="GHC.Core.TyCo.FVs.html#tyCoFVsOfType"><span class="hs-identifier hs-var">tyCoFVsOfType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Type
</span><a href="GHC.Core.Subst.html#lookupTCvSubst"><span class="hs-identifier hs-var">lookupTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865396"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680865395"><span class="hs-identifier hs-var">fv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Id -&gt; Bool
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(([Id], VarSet) -&gt; ([Id], VarSet))
-&gt; ([Id], VarSet) -&gt; ([Id], VarSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">([Id], VarSet)
</span><a href="#local-6989586621680865394"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-710"></span><span>
</span><span id="line-711"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-712"></span><span class="annot"><a href="GHC.Core.Subst.html#substTickish"><span class="hs-identifier hs-type">substTickish</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Tickish"><span class="hs-identifier hs-type">Tickish</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Tickish"><span class="hs-identifier hs-type">Tickish</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-713"></span><span id="substTickish"><span class="annot"><span class="annottext">substTickish :: Subst -&gt; Tickish Id -&gt; Tickish Id
</span><a href="GHC.Core.Subst.html#substTickish"><span class="hs-identifier hs-var hs-var">substTickish</span></a></span></span><span> </span><span id="local-6989586621680865389"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865389"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Breakpoint"><span class="hs-identifier hs-type">Breakpoint</span></a></span><span> </span><span id="local-6989586621680865387"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680865387"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680865386"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865386"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-714"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Id] -&gt; Tickish Id
forall id. Int -&gt; [id] -&gt; Tickish id
</span><a href="GHC.Core.html#Breakpoint"><span class="hs-identifier hs-var">Breakpoint</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680865387"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Id) -&gt; [Id] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="#local-6989586621680865385"><span class="hs-identifier hs-var">do_one</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680865386"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-715"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-716"></span><span>    </span><span id="local-6989586621680865385"><span class="annot"><span class="annottext">do_one :: Id -&gt; Id
</span><a href="#local-6989586621680865385"><span class="hs-identifier hs-var hs-var">do_one</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; CoreExpr -&gt; Id
CoreExpr -&gt; Id
</span><a href="GHC.Core.Utils.html#getIdFromTrivialExpr"><span class="hs-identifier hs-var">getIdFromTrivialExpr</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; Id) -&gt; (Id -&gt; CoreExpr) -&gt; Id -&gt; Id
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Id -&gt; CoreExpr
Subst -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-var">lookupIdSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865389"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-717"></span><span class="annot"><a href="GHC.Core.Subst.html#substTickish"><span class="hs-identifier hs-var">substTickish</span></a></span><span> </span><span id="local-6989586621680865381"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680865381"><span class="hs-identifier hs-var">_subst</span></a></span></span><span> </span><span id="local-6989586621680865380"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680865380"><span class="hs-identifier hs-var">other</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680865380"><span class="hs-identifier hs-var">other</span></a></span><span>
</span><span id="line-718"></span><span>
</span><span id="line-719"></span><span class="hs-comment">{- Note [Substitute lazily]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The functions that substitute over IdInfo must be pretty lazy, because
they are knot-tied by substRecBndrs.

One case in point was #10627 in which a rule for a function 'f'
referred to 'f' (at a different type) on the RHS.  But instead of just
substituting in the rhs of the rule, we were calling simpleOptExpr, which
looked at the idInfo for 'f'; result &lt;&lt;loop&gt;&gt;.

In any case we don't need to optimise the RHS of rules, or unfoldings,
because the simplifier will do that.


Note [substTickish]
~~~~~~~~~~~~~~~~~~~~~~
A Breakpoint contains a list of Ids.  What happens if we ever want to
substitute an expression for one of these Ids?

First, we ensure that we only ever substitute trivial expressions for
these Ids, by marking them as NoOccInfo in the occurrence analyser.
Then, when substituting for the Id, we unwrap any type applications
and abstractions to get back to an Id, with getIdFromTrivialExpr.

Second, we have to ensure that we never try to substitute a literal
for an Id in a breakpoint.  We ensure this by never storing an Id with
an unlifted type in a Breakpoint - see GHC.HsToCore.Coverage.mkTickish.
Breakpoints can't handle free variables with unlifted types anyway.
-}</span><span>
</span><span id="line-748"></span><span>
</span><span id="line-749"></span><span class="hs-comment">{-
Note [Worker inlining]
~~~~~~~~~~~~~~~~~~~~~~
A worker can get substituted away entirely.
        - it might be trivial
        - it might simply be very small
We do not treat an InlWrapper as an 'occurrence' in the occurrence
analyser, so it's possible that the worker is not even in scope any more.

In all these cases we simply drop the special case, returning to
InlVanilla.  The WARN is just so I can see if it happens a lot.
-}</span><span>
</span><span id="line-761"></span></pre></body></html>